UI Action condition not working es expected

Ajeet Kumar1
Mega Contributor

Hi All,

There is UI Action on problem table "Start Fix" and its out of box condition is:

current.canWrite()&&(current.state != ProblemState.STATES.FIX_IN_PROGRESS)&&new ProblemStateUtils().
validateStateTransition(current,ProblemState.STATES.FIX_IN_PROGRESS)

I wanted to it to be visible to "XYZ" group only, so i added it like:

current.canWrite()&&(current.state != ProblemState.STATES.FIX_IN_PROGRESS)&&new ProblemStateUtils().
validateStateTransition(current,ProblemState.STATES.FIX_IN_PROGRESS)&&gs.getUser().isMemberOf('XYZ')

This was working as i wanted but even it is restricting to "admin" as well if admin is not member of XYZ.

So again i changed the condition as below but it is still working as before, not showing "Satrt Fix" ui action to admin if admin is not member of XYZ.

current.canWrite()&&(current.state != ProblemState.STATES.FIX_IN_PROGRESS)&&new ProblemStateUtils().
validateStateTransition(current,ProblemState.STATES.FIX_IN_PROGRESS)&&((gs.getUser().isMemberOf('XYZ'))||(gs.getUser.hasRole('admin')))

Please check and suggest me the solution.

Thanks

 

1 ACCEPTED SOLUTION

Knight Rider
Mega Guru

Hi Ajeet,

Try replacing with this in your condition. ||gs.getUser().hasRole('admin');

View solution in original post

12 REPLIES 12

ServiceNow actually recommends changing such out-of-the-box components instead of deactivating them. So deactivating - what we also used to do - is against best practice.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you Mark and Congratulations for MVP 2020.

I didn't know that ServiceNow recommends doing that.

 I was told by my peers that when a upgrade happens it excludes upgrades for UI actions which are customized.

Im curious to know, what happens if I have to revert back to OOB button which is excluded in last upgrade.
Is there a way that we can upgrade a single UI action instead of whole instance?

 Please let me know!!

 

 

The UI Action would likely be mentioned on the Skipped Updates. After every patch and upgrade, you should go through all Skipped Updates.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank You Mark!!

I thought Skipped updates are only checked when you do a major upgrade from Release to Release. Now I'll take a note of it.

Thanks again 🙂 !!

I Mark,

I cloned the Start Fix to StartFix and put the condition you gave but still it is not visible to admin and only visible to XYZ group.

dont know how it will work 😞