The CreatorCon Call for Content is officially open! Get started here.

hiding tab component based on custom role

Vedavalli
Tera Expert

Hi

 

How to hide tab component based on custom role?

 

Thanks in advance

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Please share the screenshot where you want to do this.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

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
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

View solution in original post

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Please share the screenshot where you want to do this.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- 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
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

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