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
Hi @suuriyas 
Try the below script..
It's working for me as expected..
(function executeRule(current, previous /*null when async*/ ) {
    var opened  = new GlideDateTime(current.getValue('opened_at'));
    var resolved  = new GlideDateTime();
    var duration = GlideDateTime.subtract(opened, resolved); //the difference between opened and resolved
     current.calendar_duration = duration.getDurationValue();
})(current, previous);Also, try to perform the validation using the Business Rule condition builder instead of script evaluation
Sample:
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
HI @J Siva ,
Thanks for replying i tried the same by giving condition as resolved changes in BR before insert/update but it did not work
duration field not populated
also tried like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@suuriyas 
 var duration = GlideDateTime.subtract(resolved,opened); =>  var duration = GlideDateTime.subtract(opened, resolved);
First parameter should be start date and the second one should be end date.
current.calendar_duration = duration; => current.calendar_duration = duration.getDurationValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
HI @J Siva ,
Yeah i tried your script as well but it did not work for me
