logo

NJP

Practical UIB Examples: Hide a container/component based on the user's role

Import · Jun 03, 2022 · article
  1. Select the component or container that needs to have a dynamic visibility
  2. In the config panel, click the visibility icon
    image
  3. Click on the script icon
    image
  4. Set the visibility condition
    /** * @param {params} params * @param {api} params.api * @param {TransformApiHelpers} params.helpers */ function evaluateProperty({api, helpers}) { let user_roles = api.context.session.user.roles; let visibility_condition = user_roles.includes("THE USER'S ROLE THAT SHOULD NOT SEE THE ELEMENT"); return visibility_condition; }​
    image

Labels:

image

View original source

https://www.servicenow.com/community/next-experience-articles/practical-uib-examples-hide-a-container-component-based-on-the/ta-p/2331910