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

Having issue with Before business rule not populating fields on incident form

Rhonda9
Tera Expert

Hello, I created a business rule that is not working as expected.   I was asked to auto assign incidents if the service offering is "acd" or "call center" on the UI side to the affected user's location location support  to the Assigned to field and the location assignment group to the assignment group field fore saving the form.  What am I doing wrong?

 Insert and update is checked

 condition :    current.service_offering == 'ACD' || current.service_offering == 'Call Center'

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

// Check if the affected user (caller_id) is set
if (current.caller_id) {
// Fetch the affected user's record
var userGr = new GlideRecord('sys_user');
if (userGr.get(current.caller_id)) {
// Get the user's location
var userLocation = userGr.location; // Assuming this is the field for location

// Fetch the location record
var locationGr = new GlideRecord('cmn_location');
if (locationGr.get(userLocation)) {
// Set the Assignment Group field to the location's Location Support
current.assignment_group = locationGr.u_location_support; // Adjust field name if necessary

// Set the Assigned To field to the location's Assignment Group
current.assigned_to = locationGr.u_assignment_group; // Adjust field name if necessary
}
}
}

})(current, previous);

Thank you in advance

1 ACCEPTED SOLUTION

Still making progress - almost there.  If these are the correct custom field names on the location table, you need to force the sys_ids/values to a string type.  Here are two methods for doing that

assignment_group: locationGr.u_assignment_group.toString(), // Adjust field name as necessary
assigned_to: locationGr.getValue('u_location_support')

 

View solution in original post

17 REPLIES 17

Wow...it is working... Thank you so much for your help. I really appreciate you staying with me on this.   

You are welcome!  I'm happy to help.

 

 

Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/

Mani A
Tera Guru

Correct the trigger condition ..seems like service offering is reference field..

So correct the condition like current.service_offering.getDisplayValue()=='ACD' || current.service_offering.name=='ACD'