Ankur Bawiskar
Tera Patron

Hi @akshay parekar 

Please make your BR as Before Insert/Update and update script as this

If you keep your BR as after then you will have to use current.update() in your BR which is not good.

(function executeRule(current, previous /*null when async*/ ) {
	
	var fromdate = new GlideDateTime(current.getValue('u_start_date')); //to get start date value
	var todate = new GlideDateTime(current.getValue('u_end_date')); //to get end date value
	
	var duration = GlideDateTime.subtract(fromdate,todate);
	current.u_required_duration = duration;

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post