Show/Populate the fields lost or stolen on Asset table based on the form submission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 12:17 AM - edited 04-11-2023 01:46 AM
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.
Asset form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 04:03 AM
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:
2. Choice Values for PC Lost or Stolen?
3. Business Rule
(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
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 05:12 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 05:37 AM - edited 04-11-2023 05:56 AM
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
Anvesh