Conditional Rendering vs Page Assignements

  • 1
  • Question
  • Updated 4 years ago
  • Answered
  • (Edited)
I have a custom visualforce tab called billing that loads a Skuid page. We have created some cool ways to submit billing for different codes through this page. However, I don't want users with profiles of "Director" to be able to see the tab called "Behaviorist Billing" and I don't want users with profiles of "Behaviorist" to see the "Director Billing" tab. My first approach was going to be to use page assignments to create different pages for Director profiles and a different page for profiles with Behaviorist profiles. My understanding is page assignments work for object tabs but not for custom visualforce tabs. Correct me if I am wrong.

So my next thought was I could conditionally render the tab so only the right tab shows up based on the user profile of the user viewing the page. So I created a model called User, added the id field, the profile id, and profile name fields. I then added a condition. id = to user info of user viewing this page. I then go to the "Behaviorist Billing" tab and click on rendering and say:
Source Model: User
If no row in model: Ignore
Field: profile.name
Equals single specified value and I put in the "profile name" of the Behaviorist (I copied it from the Users profile to ensure the same spelling).

The tab disappears but when I login as a user with the correct profile, in this case "behaviorist" the tab does not show up. Any thought on the best way to approach this or what I may be missing in my setup?

Thanks
Rich
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Rich.  You should be able to create page assignment records against custom objects.  Let us know if you are not able to. 

But you should also be able to use conditional rendering here.  Some thoughts:
  • You might do the rendering against the ProfileId field instead of Profile.name.  
  • If the Behaviorist profile doesn't have the ability see or manage users, they will not be able to access the profile name.  In this case you will need to put the Profile ID  (the big long number) in the condition statement. 
Let us know if you can't get this working.  It should be feasible. 
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
I'm pretty sure this is a permissions issue like Rob said.  What I do sometimes is create a custom formula field on the User object called "Profile Name".  This allows you to give access to this field to people who would normally not have access to the Profile object.
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
I got side tracked but finally came back to this and this worked perfectly.  My roles are named based off of Geographic areas "Las Vegas Director" "Las Vegas Nurse" etc.  So now I can say if value contains "Las Vegas" render this and it works great for the whole geographic area.  Thanks!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Very Cool!