A CTASK due date cannot be modified to a date later than the Planned End Date of the CCRF

raj765_32
Tera Contributor

hi can anyone help me with the scenario and code for 

 

A  related CTASK due date cannot be modified to a date later than the Planned End Date of the related change request record.If attempted, a message should pop up stating, "The CTASK due date is later than the Planned End Date of this change. Please request an update to the CCRF prior to updating the CTASK. 

1 ACCEPTED SOLUTION

@raj765_32 Please check if this helps.

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the due date has changed
    if (current.due_date.changes()) {
        // Get the parent change request
        var changeRequest = current.change_request.getRefRecord();
        
        // Compare the due date of the change task with the planned end date of the parent change request
        if (current.due_date > changeRequest.planned_end_date) {
            current.setAbortAction(true);
            gs.addErrorMessage('The CTASK due date is later than the Planned End Date of this change. Please request an update to the CCRF prior to updating the CTASK');
        }
    }
})(current, previous);

 

View solution in original post

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@raj765_32 You need to create an onBefore Update business rule on the Change Task table with conditions Due date changes. Compare the due date field of the change task with the planned end date field of the parent change request in the script and use current.setAbortAction(true); and gs.addErrorMessage('The CTASK due date is later than the Planned End Date of this change. Please request an update to the CCRF prior to updating the CTASK'); to show the error message. 

 

Hope this helps.

Could you please help me with the script which will be so much helpful

@raj765_32 Please check if this helps.

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the due date has changed
    if (current.due_date.changes()) {
        // Get the parent change request
        var changeRequest = current.change_request.getRefRecord();
        
        // Compare the due date of the change task with the planned end date of the parent change request
        if (current.due_date > changeRequest.planned_end_date) {
            current.setAbortAction(true);
            gs.addErrorMessage('The CTASK due date is later than the Planned End Date of this change. Please request an update to the CCRF prior to updating the CTASK');
        }
    }
})(current, previous);