function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pooja ShahPooja Shah 

allow user to view the contract only if he is higher up in the role heirarchy

In a visual force page, I want to make a section of the page visible to only those people who are higher in the role heirarchy than the person who has created.

How can I can achieve the same?

Thanks in advance,

Pooja
TehNrdTehNrd
If this is for a managed package I'm not sure how you would do this dynamically and scalable. If it is a one time deal you may be able to do something like this, but first a warning.

It is definitely not the best idea ever, requires hard coding data, doesn't scale well, depending on number of roles would take a while to set up, is probably the worst advice I've given on these boards, but just might work. Hows that for a disclaimer?

You could create a map that contains the Id (key) of every user role and then a number(value). The highest role would return the number 1 and then working down the hierarchy you would add 2, 3, 4 etc for the different role levels. Then based on the UserRole and OwnerRole you can see which is higher and then determine what components on the page could be rendered.

But of course your map will break when ever a new Role is created or the hierarchy is reordered.

It would be cool if salesforce.com automatically calculated this "index" integer and it was a field on the UserRole object.



Message Edited by TehNrd on 06-18-2008 05:01 PM