UI Builder Hide button based on role

F_bio Santos
Kilo Sage

Hi everyone Im trying to hide a button on the UI Builder based on a role, I have tried many things, the last one I trying was creating a "Data Ressource" "Check for user roles" and put the role there, and then on the button "Hide Component" I tried calling this data ressource using this code:

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {TransformApiHelpers} params.helpers
 */
function evaluateProperty({ api }) {

  return !api.getData('userIsAdmin'); 
  
}

 
But it is not working, both users with the role and without the role can still see it, can anyone help with this ?

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@F_bio Santos 

which button is that? is it an declarative form action? share some screenshots.

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

F_bio Santos
Kilo Sage

Hi @Ankur Bawiskar its a "normal" button

F_bioSantos_0-1749127981956.png