Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Publish Button Should be visible only to specific user

shubhi_shubhi
Kilo Sage

Hi,

 

In DMS there is UI Action: Publish Version and that should be visible to the Document Owner, person who is having Admin role and User who is having sys_id: '97c1980fb213a9153af6871510ec72' and Publish Version button should be available only when the state of document is "Ready for publish'

 

=> I have written below code:

current.version_state == "ready_for_publish" && current.canWrite() && (current.document.owner == gs.getUserID() || gs.hasRole('admin') ||gs.getUserID() === '97c1980fb13a9153af6871510ec72')

 

Issue:

gs.getUserID() === '97c1980fb13a9153af6871510ec72'

 

user with sys_id = '97..' unable to see the button

**here I have changed the sys_id and removed some digits

Please suggest

attach.png

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@shubhi_shubhi 

are you sure the sysId is correct?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Runjay Patel
Giga Sage

Hi @shubhi_shubhi ,

 

You conditions look okay, Check two thing.

 

1. make sure sys_id given is correct for logged in user.

2. logged in user have write access to the table.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------