Based on CI assignment group needs to be populated in incident form

Arun61
Tera Contributor

@Ankur Bawiskar 

Hello,

Based on CI i have to populate the assignment group(not support or change group)

i have a group name separately if select CI(EX:- A or B or C) i have have to populate Assignment group as(ex:- test group) in case if i select a different CI apart of(A or B or C) then the group name and assigned to should no clear

Please check the below script and correct if there in any mistake please

right now working fine but when i create a new incident and if i change the ci then Assigned to value is cleaning that should not happen.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var result = false;
    var grp = g_scratchpad.formGroup;
    var ci = [];
    ci = g_scratchpad.CI.split(',');
    var groupName = g_scratchpad.group;
    var assit= g_scratchpad.assto;
    for (var i = 0; i < ci.length; i++) {
        if (newValue == ci[i]) {
            result = true;
            break;
        }
    }
    
    if (result) {
        
        g_form.setValue('assignment_group', groupName);
    } else {
        
        g_form.setValue('assignment_group', grp);
        g_form.setValue('assigned_to',assit);
    }
}

 

 

Business rule

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    g_scratchpad.CI = gs.getProperty("A B C");
    g_scratchpad.group = gs.getProperty("test group");
    g_scratchpad.formGroup=current.assignment_group;
    g_scratchpad.assto=current.assigned_to;

})(current, previous);

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So what debugging did you perform?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

I have check all the client scripts, bussiness rules i dont find anything related to this. 

if i deactivated the script it is working fine(if i change the CI to any incident assignment group and assign to is not clearing)

if it is active then assign to is clearing when i change the CI

but I could not find any script which is clearing assigned to?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

yes but assign to is clearing because of the script. if i deactivate the script it is working fine

is there any other way to achieve this requirement?