- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 10:10 AM
I'm trying to set up a field to be a simple calculated value based on a couple other fields. I can get it to populate with the values of other fields, but not with the calculated value.
So, this works:
current.gross_cost_audience = current.io_line_item_aud_ext.agency_commission;
But this does not:
current.gross_cost_audience = current.net_cost_audience * current.io_line_item_aud_ext.agency_commission;
Any ideas what I'm doing wrong here?
Also - is it possible to have it update in "real time". So, if I change the "Net" field, I can see the new "Gross" value update as I'm typing - without having the save the form?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 10:18 AM
Are you getting any errors in your log regarding the multiplication? One thing to check is that both those objects are actually numbers. You could force them to be by going ...
current.gross_cost_audience = parseInt(current.net_cost_audience) * parseInt(current.io_line_item_aud_ext.agency_commission);
Calculated fields won't update in real time. Worse, they will only change on updates to the record they're on directly. This is why you'll generally see people manage calculations via business rules, rather than field definitions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 10:41 AM
As far as I know, calculated fields will only update based on a database transaction on the record its on. Take all the SLA duration fields for example. They aren't calculated on the *view*, they're recalculated based on commands that periodically run in the back end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2016 12:17 PM
Hi rfedoruk,
You show about how the calculated fields are updated? According to Jim, these fields are updated when a record is displayed or even queried. Meaning if you got a the records in a list, it will update as well. Which I can comfirm since I had a list of records with no value, and directly after I updated the field with calculated value, all the records in the list view got the correct value.
Can read his comment here at my post: https://community.servicenow.com/community/blogs/blog/2016/06/23/calculated-value-a-pot-of-gold-at-t...