
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 01:42 PM
I apologize for the easy question but I'm new at this.
I'm attempting to modify a total score field (integer) and modify to a calculated field. I want to take 3 separate scores to get a total score. A Score + B Score + C Score = Total Score.
I'm aware I can click on calculated value tab within the table field, click calculated and add my code but I don't know where to start.
(function calculatedFieldValue(current) {
// Add your code here
return ''; // return the calculated value
})(current);
Any assistance would be appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 04:19 PM
I would not use a Calculated Field for this, but create a Business Rule instead.
Calculated fields are calculated every time a row is read, whereas the BR will only run when needed. You can setup the BR to run when required to update the field.
In your business rule, you can use below script
current.total_score = current.score_a + current.score_b + current.score_c; // update fields as per your table score fields
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 04:19 PM
I would not use a Calculated Field for this, but create a Business Rule instead.
Calculated fields are calculated every time a row is read, whereas the BR will only run when needed. You can setup the BR to run when required to update the field.
In your business rule, you can use below script
current.total_score = current.score_a + current.score_b + current.score_c; // update fields as per your table score fields
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 04:51 PM
Does it run the calculation even if the row is not included in the list?
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 04:50 PM
Also, you can't report on calculated fields.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022