- 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:17 AM
That should ideally work.
Could you please make the variable exclusively integers by using parseInt() of javscript-
current.gross_cost_audience = parseInt(current.net_cost_audience) * parseInt(current.io_line_item_aud_ext.agency_commission);
Hopefully it helps
- 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:38 AM
Sorry - didn't read your whole reply about real-time updates. Okay - I haven't done much with Business Rules. I'll have to dig into those.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 10:37 AM
That was it. Changed to parseFloats instead. This works:
var comissionMultiplier = 1.0 + parseFloat(current.io_line_item_aud_ext.agency_commission) / 100;
current.gross_cost_audience = parseFloat(current.net_cost_audience) * comissionMultiplier;
Is there any way to have that calculation run in real-time as the value of the "Net" field changes - similar to how AJAX works?