Change request Cannot Request Approval if Planned Start has passed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 05:20 AM
When submitted a Change Request, the user cannot click Request Approval if the Planned Start date is prior to the current date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 05:43 AM
As per my understanding you want to prevents users from requesting approval for a Change Request if the Planned Start date has already passed.
Create Before Update Business rule on table 'change_request'. You can set a condition to run the Business Rule only when the change request is being updated.
In the script section, check if the Planned Start date is in the past. If it is, prevent the request for approval:
var plannedStart = current.planned_start.getGlideObject(); // Ensure it's a GlideDateTime object
var now = new GlideDateTime();
if (plannedStart <= now) {
gs.addErrorMessage('Cannot request approval: Planned Start date has already passed.');
current.setAbortAction(true); // Prevent further processing
}
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 06:46 AM
Yes I want to prevents users from requesting approval for a Change Request if the Planned Start date has already passed.
Thank you for sharing this solution.
I tried with this code; it is not working as expected.
Thanks ,
Praveen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 08:24 AM
Hi ,
Yes , While submitting Change request user will not click on Request approval button. But when the user click on request approval button the Planned start date should be prior to the current date.
Could you please suggest any solution please .
Thanks,
Praveen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2024 10:43 AM - edited ‎10-17-2024 04:33 AM
Hi @praveenkumarr ,
Control the visibility or availability of the "Request Approval" button, add a condition in the UI Action for "Request Approval":
current.planned_start_date >= gs.nowDateTime()
Thanks,
Pradeep
Regards,
Pradeep