how to add script for calculation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:44 AM
I have 3 choice fields as below
1. User or Business Value (Drop down values to show: *,**,***,****,*****. Each star associated with a numerical value: * = 1; ** = 5; *** = 8; **** = 13; ***** = 20)
2. Time Criticality (Drop down values to show: Lowest, Low, Medium, High, Highest. Each value associated with a numerical value: Lowest = 1; Low = 5; Medium = 8; High = 13; Highest = 20)
3. Risk Reduction / Opportunity Enablement (Drop down values to show: Lowest, Low, Medium, High, Highest. Each value associated with a numerical value: Lowest = 1; Low = 5; Medium = 8; High = 13; Highest = 20)
I have added above choice with label as left side and value is right side numbers.
A calculation from each field should occur. The calculation should show the total of "User or Business Value + Time Criticality + Risk Reduction /Opportunity Enablement = CoD (Cost of Delay)"
how to add this in client script? how to calculate CoD?
below are few screenshots.
- Labels:
-
Case and Knowledge Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:51 AM
Hi,
You can get the value of your dropdown using g_form.getValue(User or Business Value);
var number1= g_form.getValue('User or Business Value');
var number2= g_form.getValue('Time Criticality');
var number3= g_form.getValue('Risk Reduction /Opportunity Enablement');
var num1= parseInt(number1);
var num2 = parseInt(number2);
var num3 = parseInt(number3);
var Cod=num1+num2+num3;
Please Mark this as correct if its helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:55 AM
Hi,
please share the script you started with
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
07-18-2022 02:56 AM
var costOfDelay = parseInt(g_form.getValue('field_name') + parseInt(g_form.getValue('field_name') + parseInt(g_form.getValue('field_name') ; //You can replace the field name with your fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 02:57 AM
Hi you would need 3 onchange client scripts each on the field to do calculation. Is this catalog form or from table?
if it is table i would prefer Business rule
Harish