Show/Populate the fields lost or stolen on Asset table based on the form submission

sunil kumar11
Tera Expert

Please help me with the business rule script on RITM table on below requirement.

When we submit a form based on the asset name - Auto populate State should be -  Missing  substate should be Lost OR Stolen as we select on the form.

 

Below are the screenshots.

sunilkumar11_0-1681196974074.png

 

 

Asset form

 

sunilkumar11_0-1681197382056.png

 

@Ankur Bawiskar

@shyamkumar VK 

 

 

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @sunil kumar11 ,

Are you using any WorkFlow or Flow for this catalog item? If Yes we can do it in the Flow itself, otherwise if you want it to be a Business Rule, try the following code.

1. Catalog Variables:

AnveshKumarM_0-1681210649390.png

 

2. Choice Values for PC Lost or Stolen?

AnveshKumarM_1-1681210720859.png

 

3. Business Rule 

AnveshKumarM_2-1681210924535.png

 

AnveshKumarM_3-1681210960102.png

 

AnveshKumarM_4-1681210985152.png

 

(function executeRule(current, previous /*null when async*/) {

	var almGr = new GlideRecord('alm_asset');
	if(almGr.get(current.variables.asset)){
		almGr.install_status = '8';
		almGr.substatus = current.variables.substatus;
		almGr.update();
	}
	

})(current, previous);

 

Thanks,

Anvesh

Thanks,
Anvesh

@AnveshKumar M ,

am using flow designer for this , however I had written this below logic but its not working , its failing to update in the Asset table 

var almGr = new GlideRecord('alm_asset');
var APPID = current.variables.select_the_pc_that_is_lost_or_stolen;
if (almGr.get(APPID)) {
gs.log("Here is the variable value:" + current.variables.select_the_pc_that_is_lost_or_stolen);
almGr.install_status = '8';
var pcLostOrStolen = current.variables.pc_lost_or_stolen;
if (pcLostOrStolen == 'lost') {
almGr.substatus = 'Lost';
} else if (pcLostOrStolen == 'stolen') {
almGr.substatus = 'Stolen';
}

 

can you please review this

Hi @sunil kumar11 ,

It seems you are missing almGr.update(); statement at the end as per the above script you pasted.

 

And, the following block is not required and the choice values are stolen and lost, all small letters. You are trying with First letter CAPS.

 

if (pcLostOrStolen == 'lost') {

almGr.substatus = 'Lost';

} else if (pcLostOrStolen == 'stolen') {

almGr.substatus = 'Stolen';

}

 

You can directly use, 

almGr.substatus = pcLostOrStolen;

 

 

Thanks,

Anvesh

Thanks,
Anvesh