Asset Display name with Model display name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2020 08:53 PM
Hi,
Need to write a Business rule where asset Display name should update with model display name for all the assets. Even when we create new assets.
Below is the background script I have created, should I use insert and update After business rule on product model table, please advice
var gr = new GlideRecord('alm_asset');
gr.addEncodedQuery('asset_tag=WL1111200677');
gr.query();
if(gr.next()){
gr.display_name = gr.asset_tag+ '-' +gr.model.display_name;
gr.update();
}
Please advice.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2020 09:02 PM
Hi,
Please use the below script to udpate all records
var gr = new GlideRecord('alm_asset');
gr.addEncodedQuery('asset_tag=P1000479');
gr.query();
WHILE(gr.next()) //Replaced with WHILE instead of IF
{
gr.display_name = gr.asset_tag+ '-' +gr.getDisplayValue('model');
gr.update();
}
Thanks!!
Please mark as correct and helpful!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2020 09:07 PM
Hi Rider,
what should I put in addEncodedQuery for all assets.
Is it a after business Rule on which table
Please advice.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2020 09:07 PM
You don't need that.. Just remove the ENCODEDQUERY and execute the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2020 09:09 PM
Is it a after business rule, insert and update on which table ?