hiding tab component based on custom role

Vedavalli
Mega Sage

Hi

 

How to hide tab component based on custom role?

 

Thanks in advance

2 ACCEPTED SOLUTIONS

Dr Atul - LNG
Tera Patron

Please share the screenshot where you want to do this.

View solution in original post

HI @Vedavalli 

 

 

  • Select the component or container that needs to have a dynamic visibility

  • In the config panel, click the visibility icon
    dgarad_0-1716546151883.png

     



  • Click on the script icon
    dgarad_1-1716546152117.png

     



  • 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;
    }​


     dgarad_2-1716546152056.png

View solution in original post

5 REPLIES 5

Dr Atul - LNG
Tera Patron

Please share the screenshot where you want to do this.

Hi @Dr Atul - LNG 

Vedavalli_0-1716541751120.pngVedavalli_1-1716541756768.png

In UI Builder for the component it is showing visibility there it have script .How to hide this component based on custom role.

HI @Vedavalli 

 

 

  • Select the component or container that needs to have a dynamic visibility

  • In the config panel, click the visibility icon
    dgarad_0-1716546151883.png

     



  • Click on the script icon
    dgarad_1-1716546152117.png

     



  • 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;
    }​


     dgarad_2-1716546152056.png

Hi @dgarad ,

 

It is working for OOTB roles but not working for the custom roles. For custom roles How can we achieve component hiding?

thanks in advance