The CreatorCon Call for Content is officially open! Get started here.

Incident form

ServiceNow40
Tera Contributor

Incident form Assignment Group below create one filed "Previous Assignment Group".

 

User select assignment group is Service desk and save.

Again user select assignment group is Hardware Group and save , after saved 

 

Assignment Group                 : Hardware

Previous Assignment Group : Service Desk automatically populate the incident form.

 

Using Business Rule but not working any idea help me proper code.

2 REPLIES 2

Abhay Kumar1
Giga Sage

@ServiceNow40 You need a Business Rule that triggers when the Assignment Group field (assignment_group) changes. The rule should store the previous value of assignment_group in a custom field called Previous Assignment Group (u_previous_assignment_group).

 

Hope you are using before update BR with similar to below code with enabling advance option:

// Check if the assignment_group field value has changed

if (current.assignment_group.changes() && !gs.nil(current.assignment_group)) {

    // Set the u_previous_assignment_group to the previous value of assignment_group

    current.u_previous_assignment_group = current.assignment_group.previousValue();

}

Hope this will help you.

 

Juhi Poddar
Kilo Patron
Kilo Patron

Hello @ServiceNow40 

 

If working on form level then onChange client script is the solution.

 

You can achieve this with an onChange client script on the Assignment Group field. Here’s how:

  1. Go to the Incident table and create an onChange client script.

  2. Configure it to trigger when the Assignment Group field changes.

  3. Use the script below:

JuhiPoddar_0-1731205466386.png

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }
    
    // Set 'Previous Assignment Group' with the old value of 'Assignment Group'
    g_form.setValue('previous_assignment_group', oldValue);
}

 

 

This will populate the Previous Assignment Group field with the previous value of Assignment Group whenever it changes.

 

Please hit like and mark it as an accepted solution.

 

Thank You

Juhi Poddar