Publish UI Action is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 08:51 AM
I have a script in the condition for the Publish UI Action for Knowledge but it doesn't appear to be working. My script is below.
role (kb_inc_mngt) has a Knowledge Base = Team A Knowledge Base
role (kb_cpt_mgmt) has a Knowledge Base = Team B Knowledge Base
What I am trying to solve for?
Only a member that has role kb_inc_mngt role should be able to publish articles that is in the Team A Knowledge Base
Only a member that has a role kb_cpt_mgmt role should be able to publish articles that is in the Team B Knowledge Base.
I even tried updating the script in the condition to the following: !(new KBCommon().isStackNameDialog()) && (new KBKnowledge().canPublish(current) && gs.hasRole('admin') || (kb_knowledge_base== '614ee5296f68134019bf03d9ea3ee43f' && gs.hasRole('kb_inc_mngt')) ||
(kb_knowledge_base== '587e303edbeb9f40f5a3ab8b4b9619fc' && gs.hasRole('kb_cpt_mgmt')))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 09:50 AM
Here's something to try:
Wrap your three gs.hasRole() calls together inside an additional set of parentheses so that the last half of the condition becomes this:
&& (gs.hasRole('kb_inc_mgmt') || gs.hasRole('admin') || gs.hasRole('kb_cpt_mgmt'))
That way the role check logic is handled together and independently of the other conditions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 11:28 AM
I did that and it worked okay, the issue is they need to have the publish button for their own articles but not the other teams. I don't want it removed altogether and that removed it completely.
In addition, I believe the customer is changing the requirements.
Much appreciated.
Karen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 11:45 AM
Perhaps you could have two Publish UI actions, one with a condition checking (gs.hasRole('kb_inc_mgmt') || gs.hasRole('admin')) and the other with a condition checking (gs.hasRole('kb_cpt_mgmt') || gs.hasRole('admin')).
Then inside the UI action you could display an error message when the user tries to publish something only the other role can publish.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 11:53 AM