Error in Incident form while applying UI policy

Abhi_007
Kilo Guru

Hi Team, 

We have an assignment where we have to auto populate the assignment group as per the service offering select by users but there is catch where we have to auto populate a default assignment group(for example : level 1) where the service Offering doesn't have any support group attached to it.

I have tried to implement UI policy by following condition along with script but while loading it in Incident form everything is working but the assignment group is not changing to deafult group as mentioned above rather it throws an error : onChange script error: RangeError: Maximum call stack size exceeded function () { [native code] }

1 ACCEPTED SOLUTION

Hi @Abhi_007 ,

 

Check the below code for onChange client script , this code will trigger onChange service field and get the group information from "cmdb_ci_service" table [ used column : Manage by group ] and set on incident form, the default group sys_id given ( you can change with correct sys_id );

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   //Type appropriate comment here, and begin script below
   // get the reference object of selected service on incident form
   var group = g_form.getReference("business_service");
   
   if(group.managed_by_group != ''){
	g_form.setValue("assignment_group",group.managed_by_group); // group coming from cmdb_ci_service table
   } else {
	g_form.setValue("assignment_group", 'd625dccec0a8016700a222a0f7900d06'); // sys_id of default group
   }
}

AshishKMishra_0-1699988495848.png

This code is working perfectly on my PDI.

 

Service & Assignment Group, both are not mandatory OOTB but you have use case for "mandatory" assignment group on "State" change to resolved when "Assigned to" not empty then write the separate client script to validate it,  don't mix two separate dependencies on "Service" column. 

 

-Thanks

AshishKMishra

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

13 REPLIES 13

  //Type appropriate comment here, and begin script below
   var test = g_form.getValue('service_offering');
    var test1 = g_form.getValue('assignment_group');
    //g_form.addInfoMessage('Test' + test);
   // g_form.addInfoMessage('Test1' + test1);

    if (test != '' && test1 == '') {
        //g_form.addInfoMessage('I am in If block');
        var test3 = '62bc64fc1b028110c068fb25464bcb21';
        g_form.setValue('assignment_group', test3);
        g_form.setMandatory('assignment_group', true);
 
 
while updating the service offering in incident form , it is not populating the default assignment group as per the script .(Client script- Onchange)
 
Abhi_007_0-1699981114806.png

 

 

The service offering which i have selected doesn't have any assignment group attached to it but it is not taking the default group as per the script. Please guide if i have done any mistake...and there one condition also , if we haven't select any service offering then the assignment group shouldn't be mandatory along with if the user submit the form then assignment group should be mandatory.

Hi @Abhi_007 ,

 

Check the below code for onChange client script , this code will trigger onChange service field and get the group information from "cmdb_ci_service" table [ used column : Manage by group ] and set on incident form, the default group sys_id given ( you can change with correct sys_id );

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
   //Type appropriate comment here, and begin script below
   // get the reference object of selected service on incident form
   var group = g_form.getReference("business_service");
   
   if(group.managed_by_group != ''){
	g_form.setValue("assignment_group",group.managed_by_group); // group coming from cmdb_ci_service table
   } else {
	g_form.setValue("assignment_group", 'd625dccec0a8016700a222a0f7900d06'); // sys_id of default group
   }
}

AshishKMishra_0-1699988495848.png

This code is working perfectly on my PDI.

 

Service & Assignment Group, both are not mandatory OOTB but you have use case for "mandatory" assignment group on "State" change to resolved when "Assigned to" not empty then write the separate client script to validate it,  don't mix two separate dependencies on "Service" column. 

 

-Thanks

AshishKMishra

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @Abhi_007 ,

Just checking, your issue resolved or not. 

Please mark accept solution and helpful and close this thread

 

-Thanks,

AshishKMishra


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM ,

The solution i got is bit different from what you have suggest in the thread.

 

Thanks for quick response.