How to Use Profle/Role Name in a Rendering Condition using the Running User Attributes

I have not been able to get this to work and am hoping there is a simple solution to this that I am missing. I am trying to show certain components (fields, tabs etc…) based on the running users Profile/Role Name. I tried the below and it is not working. I need to use name because of ID differences between environments. I don’t really want to have a entire page copy for a different profile as I only have a couple pieces that need to render based on User Role.

How can I achieve this?

I tried adding a formula field to the User object to get the Role > Name. But the field is not available for use in the Rendering statement list for Running User Attributes.

It’s probably not working because Role Id is a Salesforce Id and not text. I always make a model called RunningUser on the user object like so, and use it for rendering stuff :

Ah ok, I was kind of thinking it had the model there already since the conditions allow to use that small set of user properties. Makes sense though to just go get the entire user model.

When you say “Id differences between environments”, are you building a managed package, or just dealing with moving between Sandboxes tied to one Production org? If the latter, then the Ids for Profiles, Users, and Roles don’t change between Sandboxes / Production as long as they’re Sandboxes of the same Production org — the Ids are consistent.

However, if you’re building a managed package, OR if you just don’t want to deal with Ids and would rather deal with Names, then Moshe’s approach is the recommended one:

1. Create Formula Field(s) on the User object called “Profile Name” or “User Role Name”, whose formula values are “Profile.Name” and “UserRole.Name”, as needed. These are necessary because for some reason, standard users do not have access to the Profile.Name field (even for their own Profile!) directly via a Model on the User object — very annoying. But Formula Fields circumvent this limitation — any user will be able to see the Name of their Profile or Role if you create a Formula Field for this purpose.
2. Create a Model on the User object called “RunningUser” or something like that, with a Condition on it limiting the Model to return just the user record for the running user. Request your custom “Profile Name” and/or “User Role Name” formula fields.
3. IN your Rendering Conditions, have the Source Type be “Model field value” rather than Running user attribute, and point it at the RunningUser Model, and at the User Role Name or Profile Name fields.

Zach, I just followed your instructions and still can’t get this to work. It is something I actually gave up on awhile ago and am coming back to…

I am testing it out on a button, but need to use the solution in about a million other places.

Am I missing something?

Sarah.  Can you maybe send us an email (support at skuidify dot com) with a more detailed description of what you are trying to do and what is happening with it?

We want to take care of you…  

Will do.

Hi Moshe,

        My Scenario :
        I want to display the  list of all the users from specific Profile For Example (Sales Profile)
        Problem :
        It is works fine with  System Administrator profile but it does not work for Sales Profile 

Thanks In Advance !!

Most likely that profile does not have access to the profile object.  Do they have the “view setup and configuration” system permission? 

Hi Rob.

I have enable " view setup and configuration" system permission for Sales user and my filter condition works as expected.

It also enable set up option as well.

Is there any way to remove set up option for sales profile