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 UI Action is not working

Cupcake
Mega Guru

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')))

 

 

find_real_file.png

8 REPLIES 8

Rogers Cadenhe1
Giga Guru

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.

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

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.

No only one.

 

find_real_file.png