Copy Issue end date to task end date
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2025 10:29 PM
Hi all ,
I am trying to copy the issue end date to remediation task end date when creating the task if its end date later than issue end date .I have created the business rule before update but its not working its taking the default duration end date of the task only not the issue end date. I have modified the script to after update still its not working.
(function executeRule(current, previous /*null when async*/) {
var defaultDurationDays = 30;
if (!current.start_date) {
return;
}
var calculatedEndDate = new GlideDateTime(current.start_date);
calculatedEndDate.addDaysUTC(defaultDurationDays);
if (current.duration) {
calculatedEndDate = new GlideDateTime(current.start_date);
calculatedEndDate.addDaysUTC(parseInt(current.duration, 10));
}
if (current.parent) {
var issue = current.issue.getRefRecord();
if (issue && issue.end_date) {
var issueEndDate = new GlideDateTime(issue.end_date);
// Pick the earlier date
if (issueEndDate.before(calculatedEndDate)) {
current.end_date = issueEndDate.getDisplayValue();
} else {
current.end_date = calculatedEndDate.getDisplayValue();
}
current.update();
}
}
})(current, previous);
0 REPLIES 0