Change Management (Planned start date/ end date)

Akshay Jadhav1
Tera Contributor
Hello All,
We have a requirement, planned start date/end needs to be synched with the dates of task. for this 
we have created one business rule to restrict the user & show alert message if dates are not with in a range on change task

It is working properly in the "New" state. It stops updating the state of change. However, we are facing an issue when a change record is in the "Assess" or "Authorize" state.

Issue Description:
If the user approves the approval, It moves to the next state, It won't stop moving to the next state.  and the change record gets stuck in the "Assess" state.

Has anyone encountered a similar issue, and what solutions or workarounds have you implemented to ensure that change records do not get stuck in the "Assess" state? Any insights or recommendations would be greatly appreciated!
 
Steps to Replicate the Issue:
  • Create a Normal Change Record:
  • Fill in the mandatory fields and save the form.
  • Create a Change Task:
  • While the change record is in the "New" state, create a task and save it.
  • Update Planned Start/End Dates:
  • After creating the change task, if the user updates the planned start/end dates on the change record, an alert message appears.
  • Attempt to Move to Assess State:
  • If the user ignores the alert and tries to move to the "Assess" state using the request approval UI action, a business rule prevents this action.
  • Update Dates and Request Approval:
  • If the user updates the planned start/end dates and then clicks on "Request Approval," the change moves to the "Assess" state, and approval is generated.
  • Ignore Alert and Approve:
  • If the user changes the planned start/end dates but ignores the alert message and approves the change record without updating the dates on the change task, the change record becomes stuck in the "Assess" state.

Business Rule - 

AkshayJadhav1_0-1727264225825.png

 

(function executeRule(current, previous /*null when async*/ ) {

    var changeTaskGR = new GlideRecord('change_task');
    changeTaskGR.addActiveQuery();
    changeTaskGR.addQuery('change_request', current.getUniqueValue());
    changeTaskGR.query();

    if (!changeTaskGR.hasNext()) { // no tasks found
        gs.info('A: ');
        return;
    } else {
        var changeStart = new GlideDateTime(current.getValue('start_date'));
        var changeEnd = new GlideDateTime(current.getValue('end_date'));
        while (changeTaskGR.next()) {
            var taskStart = new GlideDateTime(changeTaskGR.getValue('planned_start_date'));
            if (taskStart.before(changeStart)) {
                gs.info('A:1 ');
                gs.addErrorMessage('Error! The change task date is not within range, please update the change task start/end dates to be within the Planned Start and Planned End dates of the Change');
                //changeTaskGR.setAbortAction(true);
                current.state = previous.state; //RESET STATE

                gs.info('A:1.1 ');
            }
            var taskEnd = new GlideDateTime(changeTaskGR.getValue('planned_end_date'));
            if (taskEnd.after(changeEnd)) {
                gs.info('A:2 ');
                gs.addErrorMessage('Error! The change task date is not within range, please update the change task start/end dates to be within the Planned Start and Planned End dates of the Change');
                //changeTaskGR.setAbortAction(true);
                current.state = previous.state; //RESET STATE
                gs.info('A:2.2 ');

            }
        }
    }




})(current, previous);

 
1 ACCEPTED SOLUTION

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Akshay Jadhav1 

 

I am not sure 100%  but there is no need to create BR, you can use the UI policy if i am not wrong and put that validation on task dates.  2nd, due to BR the flow is getting stuck. Please check the flow error where is stuck? Is approver added properly ?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

1 REPLY 1

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Akshay Jadhav1 

 

I am not sure 100%  but there is no need to create BR, you can use the UI policy if i am not wrong and put that validation on task dates.  2nd, due to BR the flow is getting stuck. Please check the flow error where is stuck? Is approver added properly ?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************