Hide the related list UI action New and Edit in Change form

ServiceNow10sun
Giga Guru

Hi All , 

 

I have a requirement that in Change form in the related list Ui actions button 'new' and 'Edit'  should not be visible in Authorize, Scheduled ,implement ,review  and closed stage. 

Please suggest how to achieve this. 

In all below related list the New and Edit shouldnt be visible in these states.

sunita10_0-1676862728346.png

Thank you In advance. @Ankur Bawiskar @Community Alums 

2 ACCEPTED SOLUTIONS

@ServiceNow10sun 

update as this

var answer;
if (parent.state.toString() == '-5'|| parent.state.toString() == '-4')
{
	answer = false;
}
else {
	answer = true;
}

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

View solution in original post

Ratnakar7
Mega Sage
Mega Sage

Hi @ServiceNow10sun ,

 

Please try with below script, no need to declare answer as variable.

 

 

 

 

 

answer = (parent.state==-5 || parent.state==-4)?false:true;

 

 

 

 

Ratnakar7_1-1676969534251.png

 

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
If it helps please click Accept as Solution/hit the Thumb Icon.

 

Thanks,

Ratnakar

View solution in original post

13 REPLIES 13

Hi Ankur , 

its still not working : New button is still visible in Authorize , Scheduled, Implement, Review, closed

 

sunita10_2-1676961232511.png

 

StateValue
New-5
Assess-4
Authorize-3
Scheduled-2
Implement-1
Review0
Closed3

 

sunita10_0-1676960807075.png

 

sunita10_1-1676960831366.png

var answer;
if (parent.state.toString() == '-5'|| parent.state.toString() == '-4')
{
answer = false;
}
else {
answer = true;
}

answer;

 

 

@ServiceNow10sun 

can you try this and check logs?

var answer;
gs.info('Parent state1' + parent.state);
gs.info('Parent state'2 + task.state);
if (parent.state.toString() == '-5'|| parent.state.toString() == '-4')
{
	answer = false;
}
else {
	answer = true;
}

answer;

 

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

Hi Ankur , 

 

I cannot see anything in the logs as well :

 

var answer;
gs.info('Parent state1' + parent.state);
gs.info('Parent state 2' + task.state);
if (parent.state.toString() == '-5'|| parent.state.toString() == '-4')
{
answer = false;

}
else {
answer = true;

}

answer;

 

sunita10_0-1676965950349.png

 

Hi Ankur i got the issue why its not working as related list Affected ci and impacted Ci is related to task. table , hence this script didn't work but the same script is working for other related list UI actions to hide edit and new button. i have tried with problems , incidents caused by related it . 

 

Thank you.

Script looks good. just remove '' from -5 and -4. e.g. 

ShammaSalhotra_0-1676977146861.png

 

Use the below:

 

if (parent.state == -5 || parent.state == -4)
{

answer = false;
}
else {

answer = true;
}
answer;

Regards,Shamma Negi