You need to sign in to do that
Don't have an account?
Jntshumaker
Displaying a Different Visualforce Page based on Users Profile
I'm attempting to modify an existing appexchange page/button called "massedit".
I need to modify the page to display a different set of columns based on the users profile, I was able to find the following through the Salesforce documents, problem is this code is intended for something a little bit different than what i'm trying to do:
<apex:page action="{!if($Profile.Name !='System Administrator', null,urlFor($Action.Account.Tab, $ObjectType.Account, null, true))}" standardcontroller="Account" recordsetvar="accounts" tabstyle="Account"> <!-- Replace with your markup --> This page replaces your Account home page for all users except Administrators. </apex:page>
I'm just not quite sure how to drop two separate visualforce pages within the IF statement, the page itself looks like the following, natively:
<apex:page standardController="Opportunity" recordSetVar="unused" sidebar="false"> <apex:includeScript value="{!$Resource.UtilJS}" /> <apex:form > <apex:pageBlock > <apex:pageMessages /> <apex:pageBlock > Note: All modifications made on the page will be lost if Return button is clicked without clicking the Save button first. </apex:pageBlock> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Return" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!selected}" var="opp" id="table"> <apex:column headerValue="Company" width="500px"> <apex:outputField value="{!opp.AccountID}"/> </apex:column> <apex:column headerValue="Name"> <apex:inputField value="{!opp.name}"/> </apex:column> <apex:column headerValue="Amount"> <apex:inputField required="true" value="{!opp.amount}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock>
Your problem seems to me the condition
rendered="{$Profile.Name =='Test User'}"
Try this instead
rendered="{!IF($Profile.Name =='Test User', true , false)}"
similarly for other page block
Hope will help you
All Answers
You can not create two sections <apex:page /> in a VFP. What you need to do is to create two pageBlock, pageBlockSection and render them according to profile as per your requirement. Please elaborate your problem more if it does not help you.
Thank you for the reponse, this makes sense, could you provide me with some example code of how you would display two different pageblocks based on profile?
Here is a sample code
Thank you for the quick replies, I attempted to deploy the recommendations you had:
However, when I open the page with the Profiles defined in the visualforce, nothing is display (no errors, just a "blank" salesforce page)
Your problem seems to me the condition
rendered="{$Profile.Name =='Test User'}"
Try this instead
rendered="{!IF($Profile.Name =='Test User', true , false)}"
similarly for other page block
Hope will help you
Perfect, performing just as desired.
Thank you
Just wanted to second the thank you. This was just what I needed.