Aggregate two integer fields without scripting

Mohamed Elsayed
Tera Expert

Hi All,

 

I am new to this community and ServiceNow and have zero scripting experience. So, is there any way to aggregate two integer fields without scripting? 

 

Simpley, The calculation should be: Total Units= Total Units + Add Tokens.

 

MohamedElsayed_0-1717265473512.png

 

Regards,

Mo

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Mohamed Elsayed ,

There is a way without using GlideAggregate you can simplly do like - 

Right click on the field in which you need to store the response and add this line of code 

SarthakKashyap_1-1717267729577.png

 

(function calculatedFieldValue(current) {

	// Add your code here
	var a = current.u_a;
	var b = current.u_b;
	var c = current.u_c;
	var d = current.u_d;

	return a+b+c+d;  // return the calculated value

})(current);

SarthakKashyap_0-1717267695176.png

 

For emaple in my Incident form there a 5 fields - A,B,C,D and E

E stors the sum of A,B,C,D 

 

Result

SarthakKashyap_2-1717267800617.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

View solution in original post

5 REPLIES 5

SK Chand Basha
Giga Sage

Hi @Mohamed Elsayed  

Can you refer this video it might be helpful

 

https://youtu.be/p3ddcJDmRcE?si=p_gBs8MFY9KE-bUM

 

Mark it Helpful and accept solution!! If this helps you to understand.