- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2023 08:15 AM
Hi all, so i need to calculate the percentage value in respective fields.
left side values will be filled manually.. right side it should populate autocalculation .cgst and sgst will be half % of GST that is it should show in amount . CGST : 180 , SGST : 180 ., IGST : 0 . If we clear values in CGST and SGST . then IGST should show total of CGST and SGST that is 360. can i get script for it
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2023 08:43 AM
Hi,
You can use a Client Script defined for the table where your screenshot comes, and field name of "GST%". And use similar logic as in my example:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var ua = g_form.getDecimalValue('u_amount');
var ud = g_form.getDecimalValue('u_discount');
var adjustment = (ua * (ud/100));
var total = (ua) - (adjustment);
// g_form.addInfoMessage("adjustment = " + adjustment + ", total type = " + typeof total);
g_form.addInfoMessage("ua=" + ua + ", ud=" + ud + ", total=" + total.toFixed(2));
g_form.setValue('u_grand_total', total.toFixed(2));
}
Also, review existing client scripts in your instance for other examples. And use https://docs.servicenow.com/ for related documentation, and google for javascript syntax/usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2023 08:43 AM
Hi,
You can use a Client Script defined for the table where your screenshot comes, and field name of "GST%". And use similar logic as in my example:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var ua = g_form.getDecimalValue('u_amount');
var ud = g_form.getDecimalValue('u_discount');
var adjustment = (ua * (ud/100));
var total = (ua) - (adjustment);
// g_form.addInfoMessage("adjustment = " + adjustment + ", total type = " + typeof total);
g_form.addInfoMessage("ua=" + ua + ", ud=" + ud + ", total=" + total.toFixed(2));
g_form.setValue('u_grand_total', total.toFixed(2));
}
Also, review existing client scripts in your instance for other examples. And use https://docs.servicenow.com/ for related documentation, and google for javascript syntax/usage.