Asset Display name with Model display name

Heisenberg
Tera Contributor

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.

 

 

12 REPLIES 12

Knight Rider
Mega Guru

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!!

Hi Rider,

what should I put in addEncodedQuery for all assets.

Is it a after business Rule on which table

Please advice.

 

 

You don't need that.. Just remove the ENCODEDQUERY and execute the script.

Is it a after business rule, insert and update  on which table ?