- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 11:48 AM
Do I need to create a script or use something I have in ServiceNow to develop a way to calculate the quantity of the product times the unit value to arrive at the total value?
Someone managed to help me with some logic, follow the images of where I'm going to carry out this development
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 11:30 PM
Try this code :
But u have to write this code for 2 fields.
Then copy the value in 3rd field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue != oldValue && newValue != '') {
var f1 = g_form.getValue('value1'); // give quantity name
var f2 = g_form.getValue('value2'); //give value name
if (f1 != '' && f2 != '') {
g_form.setValue('result', parseInt(f1) * parseInt(f2)); //give total name
}
}
}
Many thanks
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 11:03 PM
You need to write the on change() client script in order to achieve this.
Many thanks
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 11:17 PM
I see in the picture that the value field is in read-only
So how will you enter the value in that field?
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2021 11:30 PM
Try this code :
But u have to write this code for 2 fields.
Then copy the value in 3rd field.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue != oldValue && newValue != '') {
var f1 = g_form.getValue('value1'); // give quantity name
var f2 = g_form.getValue('value2'); //give value name
if (f1 != '' && f2 != '') {
g_form.setValue('result', parseInt(f1) * parseInt(f2)); //give total name
}
}
}
Many thanks
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2021 03:41 PM