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.

Adding field values

paradise623
Giga Expert

Hi All,

 

I have a scenario where I need to add the values of 3 fields and put the sum on a different field. For example: 

 

Field 1= 12

Field 2 = 13

Field 3 =14

 

Add 12+13+14 and put the total on Field 4

 

How would I accomplish this?

 

 

1 ACCEPTED SOLUTION

You can use onchange or onsubmit client script based on your requirements and the script would be like below:

 

   var field1 = g_form.getValue('u_field_1'); 
    var field2 = g_form.getValue('u_field_2'); 

	var sum = parseInt(field1) + parseInt(field2);
	g_form.setValue('u_field_3', sum);

 


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

View solution in original post

4 REPLIES 4

Saloni Suthar
Giga Sage
Giga Sage

Where do you have these fields?


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

You can use onchange or onsubmit client script based on your requirements and the script would be like below:

 

   var field1 = g_form.getValue('u_field_1'); 
    var field2 = g_form.getValue('u_field_2'); 

	var sum = parseInt(field1) + parseInt(field2);
	g_form.setValue('u_field_3', sum);

 


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

Hi Saloni,

I'm being asked for a field name for "onChange" however I have more than one field. I can only select one field, I can't use "onSubmit" I need onChange, 

paradise623
Giga Expert

Hi Saloni,

 

These fields are located on a custom app form.