- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2023 07:17 PM
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.
Thank you In advance. @Ankur Bawiskar @Community Alums
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 07:57 PM
update as this
var answer;
if (parent.state.toString() == '-5'|| parent.state.toString() == '-4')
{
answer = false;
}
else {
answer = true;
}
answer;
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 12:54 AM
Hi @ServiceNow10sun ,
Please try with below script, no need to declare answer as variable.
answer = (parent.state==-5 || parent.state==-4)?false:true;
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 10:34 PM - edited 02-20-2023 10:39 PM
Hi Ankur ,
its still not working : New button is still visible in Authorize , Scheduled, Implement, Review, closed
State | Value |
New | -5 |
Assess | -4 |
Authorize | -3 |
Scheduled | -2 |
Implement | -1 |
Review | 0 |
Closed | 3 |
var answer;
if (parent.state.toString() == '-5'|| parent.state.toString() == '-4')
{
answer = false;
}
else {
answer = true;
}
answer;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 10:40 PM
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;
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 11:52 PM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 08:23 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 02:57 AM - edited 02-21-2023 02:59 AM
Script looks good. just remove '' from -5 and -4. e.g.
Use the below:
if (parent.state == -5 || parent.state == -4)
{
answer = false;
}
else {
answer = true;
}
answer;