- 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-17-2023 12:36 AM
Hi @Ak8977 ,
Make sure you BR is created on Incident table and should be set as Before Insert/Update and condition as Location changes and location is not empty.
Please modify script as below:
var grLocation = new GlideRecord('cmn_location');
if(grLocation.get(current.getValue("location"))){
if(grLocation.getValue("u_street") != ''){
current.street= grLocation.getValue("u_street");
}
}
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 01:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 02:08 AM
Can you help me on this
I have same kind of scenarion, but this logic was not working over there.
I have created an asset, it automatically creates the CI. In that CI I need to set the short description as some serial number. In this case it was not working.
created the before business rule on CI table
var gr = new GlideRecord('alm_asset');
gr.addQuery('sys_id',current.asset);
gr.query();
if(gr.next()){
gr.short_description = "inside if loop";
if(!gs.nil(gr.serial_number.toString())){
current.short_description = gr.serial_number;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 02:26 AM
Update as:
var gr = new GlideRecord('alm_asset');
gr.addQuery('sys_id',current.asset);
gr.query();
if(gr.next()){
if(gr.serial_number.toString() != ''){
current.short_description = gr.serial_number.toString();
}
}
And to be very frank you dont even need script for this,
just go in the business rule and in the set values section
Select field description and same as operator and dot walk to the serial number field
that should do the trick.
Aman Kumar
- 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.