- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 04:39 AM
HI Community,
I have a requirement, in catalog form there are 2 variables (see screenshot)
whenever the value entered in Expected Yearly Mileage (km) - Total then that value needs to multiply by 36 and populate in Estimated mileage Km per 36 months
For example; if i enter 11 in first variable then 396 (36 x 11) needs to be populate in second variable how can we achieve this
Please help me with the onchange client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 05:19 AM - edited 08-19-2025 05:20 AM
There was an error in the script try below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 05:03 AM
Hi @suuriyas ,
Please write a client script - getvalue of first variable and Set it in secodn variable like - First variable value * 36. Use setvaleu and getvalue, try to write code and in case any issue, ask us.
If my answer helepd you, please mark it- solution accepted.
Regards,
Nikhil Bajaj
Regards,
Nikhil Bajaj
ServiceNow Rising Star-2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 05:17 AM
HI @Nikhil Bajaj9 ,
Thanks for replying
I tried this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 05:40 AM
Hi @suuriyas ,
If you are using getValue then use - First variable name in quotes. ex:- parseInt(g_form.getValue('u_a'));
Else use newValue firectly without getValue.
parseInt(newValue);
If my answer helped you, please mark it- solution accepted.
regards,
Nikhil Bajaj
Regards,
Nikhil Bajaj
ServiceNow Rising Star-2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2025 05:33 AM
it's an easy requirement and what did you start with?
Unless you start you won't learn.
You should write onChange catalog client script on 1st variable and ensure UI Type - ALL
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var mil = parseInt(newValue);
g_form.setValue( 'estimated_mileage', mil*36);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader