- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 12:29 AM
In the sys_user table I have a street field. I am writing a before business rule when a new user was created and we select his location then the street field map with the street field in cmn_location table.
I have written the following business rule. But it was not working.
var gr = new GlideRecord('cmn_location');
gr.addQuery('sys_id',current.location);
gr.query();
current.short_description = current.location;
while(gr.next()){
current.short_description = "inside if loop";
if(!gs.nil(gr.u_street.toString())){
current.street= gr.u_street.toString();
current.update();
}
}
current.update();
It was not going to the if loop.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 03:34 AM
Hello Aman,
we need to write async business rule,
because asset and CI are creating Simultaneously.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 04:02 AM
what's the current script and what's not working as expected?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 02:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 02:37 AM
Hello Aman, if the serial number is empty then I need to fill it with asset tag, which is not possible from field values. so I go with script. The above script you shared also not workin, it was not entering into the if loop if(gr.next()).