created a table on the table when we fill the morks from telugu to social ofter social then auto tot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 09:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 09:44 PM
Hello @pranayreddy ,
there are a few issues in the provided onChange client script, so please give it a try to the below script once and let me know how that works for you.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// Sum all subject marks and set the total
var t = parseInt(g_form.getValue('u_telugu')) || 0;
var h = parseInt(g_form.getValue('u_hindhi')) || 0;
var e = parseInt(g_form.getValue('u_english')) || 0;
var m = parseInt(g_form.getValue('u_maths')) || 0;
var sc = parseInt(g_form.getValue('u_science')) || 0;
var s = parseInt(g_form.getValue('u_social')) || 0;
var tl = t + h + e + m + sc + s;
g_form.setValue('u_total', tl);
}
🔹 Please mark ✅ Correct if this solves your query, and 👍 Helpful if you found the response valuable.
Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 09:50 PM
Hi @pranayreddy ,
it's better to go with onSubmit client script in this scenario(even better go with a before insert/update BR)
function onSubmit() {
var total = 0;
var subjects = ['u_telugu', 'u_hindhi', 'u_english', 'u_maths', 'u_science', 'u_social']
for (i in subjects) {
var tempValue = g_form.getValue(subjects[i]);
if (tempValue) {
total += parseInt(tempValue) || 0;
}
}
g_form.setValue('u_total', total);
}
with onChange you have to create 6 onchange client scripts with 6 subjects
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2025 10:15 PM
you can use before update business rule and update the total
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