- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2015 05:04 AM
Please excuse any wording errors as I am a complete newbie with this.
I am trying to populate an Integer field based on 3 other integer field values. I have done it successfully on a local form using 4 similar scripts. The first is an onLoad script for when the form is initially presented, the other 3 are onChange for when any of the underlying fields are changed, it recalculates and updates the calculated value. My fields are Cost, Value, Risk and CVRValue. All are Integers, CVRValue is also read only.
I tried setting CVRValue as a calculated field and having the script in the field, but it did not function. I also read that you should use as few Client scripts as possible to enhance performance.
Here is my onLoad script:
function onLoad() {
//JAJ calculates and prepopulates CVRValue based sum of Cost / Risk and Value entries.
var cost = g_form.getIntValue('cost');
var risk = g_form.getIntValue('risk');
var value =g_form.getIntValue('value');
var cvr = cost + risk + value; // works
g_form.setValue('cvrvalue', cvr);
}
To my questions:
Why would this not work in Calculated field, or how do you get a calculated field to work?
In my scenario, should I use a calculated field or a Client script?
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2015 04:57 AM
Hi Jim,
I've created an integer field on my own instance on incident table (field called "mycalc") and used for calculation the following script:
current.mycalc = current.reopen_count + current.child_incidents + current.severity
Checking now incidents I can see the field is populated and here is an example from an incident XML view:
<u_mycalc>3</u_mycalc>
This should work in the same way for you as well.
Have you tried it in this way?
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2015 04:57 AM
Hi Jim,
I've created an integer field on my own instance on incident table (field called "mycalc") and used for calculation the following script:
current.mycalc = current.reopen_count + current.child_incidents + current.severity
Checking now incidents I can see the field is populated and here is an example from an incident XML view:
<u_mycalc>3</u_mycalc>
This should work in the same way for you as well.
Have you tried it in this way?
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2015 07:46 AM
Thank you Sergiu, appreciate the assistance, it works.