Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2022 11:43 PM
Hi
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
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader