How to Hide "New" Button on Change Task Related List When Change Request State is "Scheduled".

tilekarnilesh
Giga Guru

Hi everyone,


On the Change Request form, we needed to hide the "New" button on the Change Task related list whenever the state is changes to "Scheduled".

tilekarnilesh_0-1751635299170.png

 

3 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@tilekarnilesh 

you can configure list control and then use Omit new condition script field

AnkurBawiskar_0-1751635939633.png

 

// if CHG is active and state is not scheduled then show
if (parent.active && parent.state.toString() != '-2')
    answer = false; // show
else
    answer = true; // omit

AnkurBawiskar_1-1751636011301.png

 

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

@tilekarnilesh 

Thank you for marking my response as helpful.

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

@tilekarnilesh 

yes you will have to replace the existing one with the one I shared.

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

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@tilekarnilesh 

you can configure list control and then use Omit new condition script field

AnkurBawiskar_0-1751635939633.png

 

// if CHG is active and state is not scheduled then show
if (parent.active && parent.state.toString() != '-2')
    answer = false; // show
else
    answer = true; // omit

AnkurBawiskar_1-1751636011301.png

 

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

tilekarnilesh_0-1751636460278.png

@Ankur Bawiskar  This script is already present here.
Also, I noticed that the value for the "Scheduled" state is -2.
Can you please confirm:
If the state is "Scheduled" (i.e., -2), will the "New" button on the Change Task related list be hidden?

@tilekarnilesh 

yes you need to add the extra condition as per what I shared

when state is -2 the IF condition won't run, it will go to ELSE and set answer=true

when answer=true it means it will omit

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

@tilekarnilesh 

Thank you for marking my response as helpful.

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