Need to close the change task for cancelled change request, for change task state field is gryedout

mohanmerava
Tera Contributor

@Ankur Bawiskar can you help me with below issue.

We need to close the long back created change tasks were state field is greyed out in draft state.already change request is in cancelled state. But still change task are in draft state. Tried background script to close those but still state is not getting changed. Can you please help me on this 

1 ACCEPTED SOLUTION

@mohanmerava 

your script is wrong

try this

var gr = new GlideRecord('change_task');
gr.addQuery('number', 'ctasknumber');
gr.query();
if (gr.next()) {
    gr.state = 140;
	gr.setWorkflow(false);
    gr.update();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Hi @mohanmerava 

 

Is any error you are getting.

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

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

No error atul

Hi @mohanmerava 

 

I believe there’s a property causing this issue. Take a look at the Change → Cancel Change property. Try disabling it and see if that resolves the problem.

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

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

Ankur Bawiskar
Tera Patron
Tera Patron

@mohanmerava 

you didn't share complete script. Please share the complete one

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Below code is used Ankur

var gr = new GlideRecord('change_task');

 

 

 

  gr.addQuery('number', 'ctasknumber');

 

 

 

  gr.query();

 

gr.state= 140;

 

gr.update();