Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Publish Button Should be visible only to specific user

shubhi211
Tera Guru

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
Tera Patron

@shubhi211 

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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Runjay Patel
Giga Sage

Hi @shubhi211 ,

 

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

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