- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
3 weeks ago - last edited 3 weeks ago
There was an error in the script try below:
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
HI @Nikhil Bajaj9 ,
Thanks for replying
I tried this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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