Display business rule is not working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2023 02:46 AM
I want to fetch Location data to my incident form, by using display business rule and onchange client script but this is not working. please help .
Display BR:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
g_scratchpad.location = current.caller_id.location.name;
})(current, previous);
On change Client script:
On change Client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var location = g_scratchpad.location;
g_form.setValue('u_callers_location', location);
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2023 07:09 AM
business rule script is correct, but your onChange will only work when the field changes.
I believe you want an onload client script to set the location so use onLoad and this line of code
function onLoad(){
var location = g_scratchpad.location;
g_form.setValue('u_callers_location', location);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader