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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 02:54 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 03:04 AM
Hi,
you can have before update BR with condition as below and then set the field values using script
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 03:40 AM
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.
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..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 03:45 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 05:02 AM
Hi Ankur,
Have tried to implement the same code as you mentioned, but still no luck :(. Its not getting captured in the gs.info.