Condition for button was not working

Fahimas
Tera Contributor

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

                

1 ACCEPTED SOLUTION

Community Alums
Not applicable

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.

View solution in original post

19 REPLIES 19

Fahimas
Tera Contributor

no it was not working

Fahimas
Tera Contributor

I also written some code for on hold button which also not working

code: current.state===3&&(gs.getUser()===current.assignment_group||current.assigned_to)

Let me know what was wrong with these also.

Hello @Fahimas 

 

Please use gs.getUserID() == current.assigned_to 

 

And by the condition current.assignment_group - what did you want to achieve by this ? 

 

Also for you check all the steps that I mentioned above ? 

 

Regards, 

Shivalika 

 

LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

YouTube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=8vHknTGfxDTNkcx9

 

My condition was when the state was on onhold and the loggedin user was in the assignment group field and assigned to field but my code was not working 

Medi C
Giga Sage

Hi @Fahimas,

Could you please use?

current.state == "1" && gs.getUser().isMemberOf(current.assignment_group)

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.