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

Hi @AshishKM , 

The below screen shot where i have blacked is the default assignment group, i cannot share the details of the assignment group as per customer privacy.

 

Thanks

That's Ok, 

Question to you : you have mention "we have to auto populate the assignment group as per the service offering select by users" , why not setting the default assignment group at the same place. How are you setting the assignment group for selected "Service Offering" , any onChange client script applied, if yes, then use the same client script for default group. You don't need to write UI policy externally.  

 

If it's not a client script then find out how it is doing currently and share the details.


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

I haven't written any Client script for the same as i am using only UI policy as per the requirement. I have also shared the screen shot of the UI policy condition .

means .. you have written UI Policy for existing "auto populate the assignment" , so there are more that one UI Policy trying to update the assignment group. I would suggest keep one client script instead of 2-UI Policy. 


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

Ok let me check once and i will update to you