How to add multiple duration fields?

Jaydee1
Tera Guru

Hi All,

How to add two duration type of fields in servicenow? When I am trying to add the fields, it's getting concatenated in string form.

Can anyone help me on this issue.

Thanks in advance!!

Jaydee

3 REPLIES 3

Community Alums
Not applicable

Hi @Jaydee1 ,

 Can you share some screenshots please to show this concatenation.

ersureshbe
Giga Sage
Giga Sage

Hi, I hope, you are aware, the '+' operator is an overloading operator. Because it will do sum and concatenation. I'm not sure where you applied the code and what basis. If we know we can guide you.

 

In General, if '+' not helping you can use GlideAggregate() function.

Regards,
Suresh.

Anurag Tripathi
Mega Patron
Mega Patron

Try this in a BR 

 

var timems =0;
var tm = 0;
tm = current.[duration field 1].dateNumericValue();
timems += tm;
tm = current.[duration field 2].dateNumericValue();
timems += tm;
current.[total duration field].setDateNumericValue(timems); //this has the sum

 

-Anurag