how to compare a currency field in a business rule to populate certain fields.For example, want to check if cost is >= usd 0, then how how should i parse it in a business rule?

Divi
Mega Guru

how to compare a currency field in a business rule to populate certain fields.For example, want to check if cost is >= usd 0, then how how should i parse it in a business rule?

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can have before update BR with condition as below and then set the field values using script

find_real_file.png

If you want to use script to check then use this

var value = current.<currency_field>.getReferenceValue();

if(value > 0){

// set field values

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Thanks for the reply, but I have already tried this code but it did not work.also tried parse(<current.field>.getReferenceValue), it too didn't seem to help.

find_real_file.png

As you can see the above code, when the product's cost is 0 its not getting even captured in the logs, although values other than 0 are being captured..

 

Hi Divi,

use this instead of current.total_cost

var value = current.total_cost.getReferenceValue();

gs.info('Total Cost is: ' + value);

if(value > 0){

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Have tried to implement the same code as you mentioned, but still no luck :(. Its not getting captured in the gs.info.