- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 09:17 AM
Dear team,
Iam new to serviceNow, i have an issue that my button is not visible even wheb the condition was true!
my condition is: current.state === 1 && gs.getUserID().isMemberOf(current.assignment_group)
explanation: the button must be visible when the state was new and the loggedin user was a member of the current assignment group.the button was not visible evn when condition become true.i impersonate myself as an member of the assignment grp and state was new but the prblm ws button wasnt visible.
preview: i have checked form button
i have checked everything from reading other article evnthough itwasnot working
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2025 09:03 PM
Hi @Fahimas ,
The type of current.state will return an object and when you compare an object with number it will return you false, since you are using AND operator when the initial condition is false it will not test the other conditions. You can use == to compare state value.
And instead of getUserID use getUser(). getUser() return entire user object where as getUserID() return only the sys_id of the particular user.
current.state == 1 && gs.getUser().isMemberOf(current.assignment_group)
Mark this helpful/ Accept the solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2025 09:03 PM
Hi @Fahimas ,
The type of current.state will return an object and when you compare an object with number it will return you false, since you are using AND operator when the initial condition is false it will not test the other conditions. You can use == to compare state value.
And instead of getUserID use getUser(). getUser() return entire user object where as getUserID() return only the sys_id of the particular user.
current.state == 1 && gs.getUser().isMemberOf(current.assignment_group)
Mark this helpful/ Accept the solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 04:30 AM
Thanks for your help , it worked abundantly.
i have one request that i also have an issue with onhold button
condition: current.state == 2&&(gs.getUser().isMemberOf(current.assignment_group)||(gs.getUser===current.assigned_to))
code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2025 11:18 PM
Hello @Fahimas,
Apologies for delayed response. You can try below code snippet.
current.state = 3;
current.update();
g_form.setMandatory('hold_reason',true);
g_form.setMandatory('comments',true);
Mark this helpful/ Accept the solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2025 05:37 PM
Hi @Community Alums
I have tried them but the state was not changing to on hold . What is problem with these !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 11:50 PM
HI @Fahimas ,
When setting option items for a choice list, always use the value of the option instead of the text. Using the text may prevent the choice list from updating correctly.
Additionally, the methods setVisible(), setReadOnly(), and setMandatory() accept a boolean as the second argument, which determines the action they perform.