Add an hour to time field in incident form
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
i am trying to add an extra hour in time in time field but i face some problem .
this is my code running on before update
(function executeRule(current, previous /*null when async*/) {
var gt = new GlideTime(current.u_customtime);
var newTime = gt.addSeconds(300);
current.setValue('u_customtime', newTime);
})(current, previous);
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
syntax is different, this should work fine
1) you should use GlideDateTime
2) addSeconds() doesn't return anything
(function executeRule(current, previous /*null when async*/ ) {
var gt = new GlideDateTime(current.u_customtime);
gt.addSeconds(3600); // 1 hour is 3600 seconds
current.setValue('u_customtime', newTime.getValue());
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader