- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 10:03 AM
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 08:26 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 08:48 PM
(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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 04:54 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 08:26 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 08:48 PM
(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);