Business Rule not setting Reference Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 11:25 AM
I'm currently trying to run a before business rule that will set the built-in "location" field in the "Users" (sys_user) Table based on a custom "location" (u_location) string field on the same table. The issue is that no matter what I try, the built-in "location" field isn't being set.
I can see in the session log that it looks like it's setting the sys_id of the cmn_location record to the reference field, but the field still appears blank.
Here is a copy of my before business rule:
(function executeRule(current, previous /*null when async*/) {
// Query the Locations (cmn_location) Table
// Find a record that contains the value of the custom location field (u_location)
var gr = new GlideRecord('cmn_location');
gr.addQuery('u_name_and_address', "CONTAINS", current.u_location);
gr.query();
// Set the value of the built-in location field (location) to the sys_id of the Location Table record
if (gr.next()) {
current.location = gr.sys_id;
}
})(current, previous);
I have already tried all of suggested solutions in the following posts, to no avail:
- Business Rule is not setting the reference field value
- Setting value of reference fields using Business Rule
- Setting a reference field in business rule isn't working correctly
- how to use business rule to set reference field based on string value
Any help would be much appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2024 09:23 AM
Hey Sandeep,
I updated the script as you suggested. Still seeing the same result. I also confirmed there is no reference qualifier on the OOTB location field.