change

G5
Kilo Contributor

#Create a task -

 

On the Change form when all the change tasks associated with that change request get closed, the state of change should also set to “Close complete”.

2 REPLIES 2

Bhavya11
Kilo Patron

hi @G5 ,

 

from OOTB process flow of the change is  once every Change task [CTASK]is closed moved the change to review state.

but if you want to move the Change should be Close then you need to make sure "Close Code" and "Close Notes" are added also there is no "Close Complete" state in change from OOTB instead "Closed" state present.

 

if you want to mimic this then create Business Rule of Change task table and add the condition state changes to closed

 

Bhavya11_0-1723791861285.png

 

Script: 

 

var grCTask = new GlideRecord("change_task");
grCTask.addQuery("change_request", current.change_request.sys_id); // Get all tasks for the change request
grCTask.addActiveQuery(); // Check if any tasks are still active (not closed)
grCTask.query();

if (!grCTask.hasNext()) { // If no active tasks found, then all tasks are closed
    var grChange = new GlideRecord("change_request");
    if (grChange.get(current.change_request.sys_id)) { // Retrieve the related change request
        grChange.state = "3"; // Assuming '4' is the state value for 'Closed Complete'
        grChange.close_code = current.close_code; // Set close code from the current change task
        grChange.close_notes = current.close_notes; // Set close notes from the current change task
        grChange.update();
    }
}

 

 

Output:

 once all the CTASK closed then moved the change will move to the close with last closed CTASK code and close note will be copied to the change

 

Please mark helpful & correct answer if it's really worthy for you.

 

 

Thanks,

BK

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @G5 

 

Your requirement is not valid at all, the reason

- Every task in change has a close code - Successful / Unsuccessful / Success with issues.

- If you want to close the change then what should be the change close code?

- You are bypassing Review state and directly moving to close, which means you are missing one step if it is change is failed?

- Also a change has only closed state not closed complete.

 

Recommendation- Please check the exact requirement, before you create technical debt for your customer. 

*************************************************************************************************************
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]

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