How to add multiple duration fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2023 01:16 AM - edited 02-02-2023 03:25 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2023 06:06 AM
Hi @Jaydee1 ,
Can you share some screenshots please to show this concatenation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 02:18 AM
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.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 02:32 AM
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