Display UI action button based on role

chanikya
Kilo Sage

Here we have "Republish " button, it should be visible only   ---who are having " kb_retire" role     OR     who are the author in KB article.                                                                                                                                                             My condition is not working.....

if you see below image i am not a Author of this article and i don't have kb_retire   role, but it is visible me

it should be visible only=-------who are having " kb_retire" role         OR             who are the author in KB article.  

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

can you try now




gs.getUser().getRoles().indexOf('kb_retire') >= 0 || current.author==gs.getUserID() ||   !(gs.getUser().getRoles().indexOf('admin') >= 0 )  


View solution in original post

32 REPLIES 32

chanikya i have tested and it is working at my end.



updated condtion:



gs.getUser().getRoles().indexOf('kb_retire') >= 0 || current.author==gs.getUserID() ||   !(gs.getUser().getRoles().indexOf('admin') >= 0 )


my last concern



now i am having Kb_retire role as well as i have admin role but   "Republish button is visibled to me



find_real_file.png


you have used or (||) operator so any one of those condition will fulfill that will show the ui action.



is this not ok if those users are fulfilling both the condition


Can you please check it once,



why it is not reflecting now. i ahv etwo roles, Admin , Kb_retire, But "Republish is not appeared.



find_real_file.pngfind_real_file.png


Shusovit
Mega Expert

Add condition in the condition filed like: gs.hasRole('incident_coordinator');



find_real_file.png



Hit like or helpful or correct if this helps you.