Change request Cannot Request Approval if Planned Start has passed

praveenkumarr
Tera Expert

When submitted a Change Request, the user cannot click Request Approval if the Planned Start date is prior to the current date.

5 REPLIES 5

Rajesh Chopade1
Mega Sage

hi @praveenkumarr 

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

praveenkumarr
Tera Expert

Hi @Rajesh Chopade1 

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

praveenkumarr
Tera Expert

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

 

Pradeep Thipani
Mega Sage

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 

"If this response was useful, please select 'Accept as Solution' and mark it as 'Helpful.' This helps me provide better answers and assists the community ".

Regards,
Pradeep