Publish Button Should be visible only to specific user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 07:43 PM - edited 01-07-2025 08:19 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 08:17 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 08:39 PM
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
-------------------------------------------------------------------------
