- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 05:55 AM
I need your help with a UI action on a related list of a change. I need to introduce the condition that the button disappears if the state of the change is implement, review, or scheduled. Can you help me?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 06:27 AM
Hi @Maria Sol Arauz ,
put this in the omit new script
var state = parent.state
if (state == -1 || state == -2 || state == 0)
answer = true
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 06:29 AM
are you comparing correct state values?
also if you want to omit then ensure answer=true in script is set
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 07:50 AM
Hi @Maria Sol Arauz,
Correct. This is why I reversed the logic us not equal to ("!=")
I'm glad you got to the solution.
This also works using inverse logic:
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 06:55 AM - edited ‎04-09-2025 06:55 AM
Hi @Maria Sol Arauz and @Ankur Bawiskar - I'm not sure how this response solves the issue.
Based on the script provided, it's a logic issue.
Check my response and solution which resolves the issue. Providing this response so as to help @Maria Sol Arauz and the community when looking back at this in the future.
As the condition is for omitting, it's a double negative as it were. Additionally, you can't use || when checking for multiple values. It needs to be an && check.
if (parent.state != -2 && parent.state != -1 && parent.state != 0) { answer = false; } else{ answer = true; }
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 06:48 AM
Hi @Maria Sol Arauz,
Change your script to the following. This is tried and tested on my PDI.
(It's a logic thing... when you use || (or) you still match the other conditions.) The below resolves this.
if (parent.state != -2 && parent.state != -1 && parent.state != 0) {
answer = false;
}
else{
answer = true;
}
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 07:32 AM
Since the button is "omit new button," the values of the answer must be true for the condition you want to hide it. I was doing it the other way around.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 07:50 AM
Hi @Maria Sol Arauz,
Correct. This is why I reversed the logic us not equal to ("!=")
I'm glad you got to the solution.
This also works using inverse logic:
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 06:27 AM
Hi @Maria Sol Arauz ,
put this in the omit new script
var state = parent.state
if (state == -1 || state == -2 || state == 0)
answer = true
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya