Duration field should contain the time from the time opened to resolved.
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
HI Community,
I have a requirement, in scoped application table called K case in this table we have field called opened at and resolved at where it show date and time of the case opened and resolved and there is field called duration.
In this duration field i need to populate the value with time from opened to reloved.
i tried using BR and also used dictionary override with override calculation but both are not working.
and in calculation part .datediff is not valid it seems
my script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@suuriyas Did you debug your script?
Add log message and see what it's returning.
I just tried in my PDi, it's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
HI @J Siva ,
Yeah i tried but it did not work so went with other method.
Made BR as inactive and in dictionary override i added the calculation like this it works but even when the resolved state is empty some value is getting store in duration field like 11 hours something like that.
i have submitted a new request and when i see in table opened field is showing value state is new and no value in resolved field as expected buy in duration some random value is getting displayed like 11 hours and once i make it resloved now it is calculating correctly any reason why
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
solution:
if (!current.opened_at.nil() && !current.resolved_at.nil()){
var opened = new GlideDateTime(current.getValue('opened_at'));
var resolved = new GlideDateTime(current.getValue('resolved_at'));
var duration = GlideDateTime.subtract(opened, resolved); //the difference between opened and resolved
current.calendar_duration = duration.getDurationValue();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Just a tip..
You can replace the below with the business rule filter condition
current.opened_at.nil() && !current.resolved_at.nil()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
please use script shared by @J Siva
Debug and see, it should work ideally
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
