- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 11:59 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 06:39 AM
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')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 06:47 AM
Wow...it is working... Thank you so much for your help. I really appreciate you staying with me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 07:59 AM
You are welcome! I'm happy to help.
Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 05:25 AM
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'