Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Multiply with value and display total value in other field

prasad8
Giga Expert

My requirement :

I have created choice field with 0,1,3,9 choices. i need to multiply with 10 and caluculate total value and display in Total field.

If user selects 3 in first field i need to multiply with 3*10  and populate total value into Toatl field.

find_real_file.png

I need to configure same functionality for five fields.

please help on this script.

 

Thanks,

Prasad.

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

hello,

Write a onchange client script on the number field that whenever someone chooses a number total score is filled

Please use the below script

var num= g_form.getValue('fieldname');

var multiply=parseInt(num)*10;

g_form.setValue('totalscore_fieldname',multiply);

Please mark answer correct/helpful based on Impact

View solution in original post

2 REPLIES 2

palanikumar
Giga Sage
Giga Sage

You can create onChange client script on "Reduce Working Capital" field and add the below script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (newValue === '') {
        g_form.setValue('u_total_score','0');
        // Replace u_total_score with actual field name of Total Score
    }
    var value = parseInt(newValue) * 10;
    g_form.setValue('u_total_score',value.toString());
    // Replace u_total_score with actual field name of Total Score
}

Repeat same for other fields

Thank you,
Palani

Saurav11
Kilo Patron
Kilo Patron

hello,

Write a onchange client script on the number field that whenever someone chooses a number total score is filled

Please use the below script

var num= g_form.getValue('fieldname');

var multiply=parseInt(num)*10;

g_form.setValue('totalscore_fieldname',multiply);

Please mark answer correct/helpful based on Impact