Issue with before Business Rule If condition

MohanambalN
Tera Contributor
In alm_asset table I have created the below Business Rule(OnBefore) which runs on insert and update.
 
But it always going to else part and updating Serial number in the Device Name.
If it is communication Device, then it should update the IMEI number as device name. 
 
(function executeRule(current, previous /*null when async*/)
{
   
var communicationDevice = gs.getProperty("itsm.asset.model_category.communication_device.sys_id");
var modelCategory = current.getValue('model_category');  //(category sys ID)
 

 

gs.log("Model Category :"+modelCategory);
gs.log("Model Cqategory1 :"+communicationDevice);

 

if (modelCategory == communicationDevice)
{
    current.setValue('u_device_name', current.u_imei_number);
}
else
{
    current.setValue('u_device_name', current.serial_number);
}

 

})(current, previous);
 
Please someone help me to fix the issue.
 
Thanks
11 REPLIES 11

Anurag Tripathi
Mega Patron
Mega Patron

What are you getting in these logs

 

gs.log("Model Category :"+modelCategory);
gs.log("Model Cqategory1 :"+communicationDevice);
-Anurag

Hi Anuraga,

 

In logs Sys ID of the Communication Device model category is coming.

 

Thanks

check if there are any additional spaces or something that might be causing the match to fail.

-Anurag

Vrushali  Kolte
Mega Sage

Hello @MohanambalN ,

 

Can you rewrite your if condition as below and try it -

 

 

 
if (modelCategory == communicationDevice + '')
{
    current.setValue('u_device_name', current.u_imei_number);
}

 

If my answer solves your issue, please mark it as Accepted & Helpful!