How to validate change task planned start date and planned end date falls within the change planned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 11:32 AM
Hai to everyone,
I have one requirement how to validate change task planned start date and planned end date falls within the change planned start date and planned end date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 03:52 PM
To validate that a Change Task's planned start date and planned end date fall within the Change's planned start date and planned end date, you can use a Business Rule or a Client Script.
Here is an example Business Rule that you can use:
- Navigate to Change Task [change_task] > Business Rules and click on New.
- Name the Business Rule and set the Active checkbox to true.
- In the Advanced section of the Conditions tab, enter the following condition:
current.planned_start_date < current.parent.planned_end_date && current.planned_end_date > current.parent.planned_start_date
- In the Advanced section of the Scripts tab, enter the following script:
if (current.planned_start_date < current.parent.planned_end_date && current.planned_end_date > current.parent.planned_start_date) {
gs.addInfoMessage('The planned start and end dates for this Change Task fall within the planned start and end dates for the parent Change.');
} else {
gs.addErrorMessage('The planned start and end dates for this Change Task do not fall within the planned start and end dates for the parent Change.');
current.setAbortAction(true);
}
This Business Rule will trigger whenever a Change Task is inserted or updated, and will check if the planned start and end dates for the task fall within the planned start and end dates for the parent Change. If they do not fall within the parent Change's dates, an error message will be displayed and the transaction will be aborted.
You can modify this script to suit your specific requirements, such as changing the error message or using a different severity level for the message.
I hope this helps! Let me know if you have any further questions or need more information.
Please mark my answer as a solution/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal.
Thanks,
Punit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 08:04 PM
