Change Request - Actual Start Date Alteration

Swebb
Tera Contributor

Hi Everyone,

 

I have created a script to not allow the Actual Start Date for a Change Request to be populated before the approval date. The script below does that but also doesn’t allow for the Actual Start Date to be the same day as the approval date. Does anyone know how I can alter this script to not allow for the Actual Start Date be before the approval date but still allow for same day submittal.

 

(function executeRule(current, previous /*null when async*/) {
// Check if the Actual Start Date is provided
if (current.work_start.nil()) {
// Actual Start Date is empty, no further checks needed
return;
}
// Check if the Actual Start Date is before the Approval Date or Planned Start Date
if (current.work_start < current.approval || current.work_start < current.start_date) {
gs.addErrorMessage("Actual start date must be after the Approval Date and Planned Start Date");
current.setAbortAction(true);
}
})(current, previous);

2 ACCEPTED SOLUTIONS

Amit Gujarathi
Giga Sage
Giga Sage

HI @Swebb ,
I trust you are doing great.

 

Here's the revised script:

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the Actual Start Date is provided
    if (current.work_start.nil()) {
        // Actual Start Date is empty, no further checks needed
        return;
    }
    // Check if the Actual Start Date is before the Approval Date
    // and if it is before or the same as the Planned Start Date
    if (current.work_start < current.approval || current.work_start <= current.start_date) {
        gs.addErrorMessage("Actual start date must be after the Approval Date and on or after the Planned Start Date");
        current.setAbortAction(true);
    }
})(current, previous);
 

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

(function executeRule(current, previous /*null when async*/) {
// Check if the Actual Start Date is provided
if (current.work_start.nil()) {
// Actual Start Date is empty, no further checks needed
return;
}

// Check if the Actual Start Date is before or the same day as the Approval Date or Planned Start Date
if (current.work_start < current.approval || current.work_start < current.start_date || current.work_start == current.approval) {
gs.addErrorMessage("Actual start date must be after the Approval Date and Planned Start Date");
current.setAbortAction(true);
}
})(current, previous);

View solution in original post

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

If you want to check both Approval Data and Planned start date, it should be an &&. And you can try <= to see if that works.

if (current.work_start <= current.approval && current.work_start <= current.start_date) {


Please mark this response as correct or helpful if it assisted you with your question.

Amit Gujarathi
Giga Sage
Giga Sage

HI @Swebb ,
I trust you are doing great.

 

Here's the revised script:

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the Actual Start Date is provided
    if (current.work_start.nil()) {
        // Actual Start Date is empty, no further checks needed
        return;
    }
    // Check if the Actual Start Date is before the Approval Date
    // and if it is before or the same as the Planned Start Date
    if (current.work_start < current.approval || current.work_start <= current.start_date) {
        gs.addErrorMessage("Actual start date must be after the Approval Date and on or after the Planned Start Date");
        current.setAbortAction(true);
    }
})(current, previous);
 

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



(function executeRule(current, previous /*null when async*/) {
// Check if the Actual Start Date is provided
if (current.work_start.nil()) {
// Actual Start Date is empty, no further checks needed
return;
}

// Check if the Actual Start Date is before or the same day as the Approval Date or Planned Start Date
if (current.work_start < current.approval || current.work_start < current.start_date || current.work_start == current.approval) {
gs.addErrorMessage("Actual start date must be after the Approval Date and Planned Start Date");
current.setAbortAction(true);
}
})(current, previous);