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
SF7SF7 

Fields view according to profiles

Hi,

 

i have a vf page for contacts and in the top section of the page i.e contact information in that all the fields are not available for all the profiles so it should just leave a blank space for the fileds wich do not have permission but whats happening is its changing the fileds placement from left to right can any one help with this.

<apex:page tabStyle="contact" standardController="Contact" extensions="ContactDetailExtensionController">

<apex:form id="contactForm">

<apex:pageBlock title="{!$Label.conDetail_ContactDetail}" mode="maindetail">
<apex:pageBlockButtons >
                    <apex:commandButton value="{!$Label.conDetail_Edit}" action="{!edit}" />
                    <apex:commandButton value="{!$Label.conDetail_Delete}" action="{!delete}" />
                    <apex:commandButton value="{!$Label.conDetail_ContactHistoryRpt}" onclick="window.open('/00O30000003gp3O?pv0={!Contact.Id}','ContactHistoryReport','width=800,height=600,scrollbars=yes')" />
                    <!-- <apex:commandButton value="Clone" action="{!clone}" rendered="{!checkLevel2or3SysAdmin}" /> -->
</apex:pageBlockButtons>
<apex:outputPanel >
<apex:pageBlockSection collapsible="true" title="{!$Label.conDetail_ContactInfo}" showHeader="true">
    <apex:pageBlockSectionItem >
   
        <apex:outputLabel value="{!$Label.conDetail_ContactName}" for="theContactName"/>
        <apex:outputField value="{!contact.name}" id="theContactName"/> 
       
    </apex:pageBlockSectionItem>
      <apex:outputField value="{!contact.phone}" rendered="{!accessContactContactInformation}"/>
      <apex:pageBlockSectionItem >
     
      <apex:outputLabel value="{!$Label.conDetail_AltContactName}" for="theContactAlternateName"/>
      <apex:outputtext id="theContactAlternateName" Value="{!contact.Alternate_First_Name__c} {!contact.Alternate_Last_Name__c}"/> 
   
    </apex:pageBlockSectionItem>
  
      <apex:outputField value="{!contact.mobilephone}" rendered="{!accessContactContactInformation}"/>
      <apex:outputText value="" rendered="{!accessContactContactInformation==false}"/>    
     
     
      <apex:outputField value="{!contact.accountId}"/>     
      <apex:outputText value="" rendered="{!accessContactContactInformation==false}"/>  
   
      <apex:outputField value="{!contact.email}" rendered="{!accessContactContactInformation}"/>
      <apex:outputField value="{!contact.title}"/>  
      <apex:outputField value="{!contact.Secondary_Email__c}" rendered="{!accessContactContactInformation}"/>
      <apex:outputText value="" rendered="{!accessContactContactInformation==false}"/>
      <apex:outputField value="{!contact.Management_Level__c}" /> 
      <apex:outputField value="{!contact.fax}" rendered="{!accessContactContactInformation}"/>
      <apex:outputField value="{!contact.Functional_Area__c}"/>  
      <apex:outputField value="{!contact.Critical_Contact__c}"/> 
      <apex:outputText value="" rendered="{!accessContactContactInformation==false}"/>
      <apex:outputField value="{!contact.department}"/>
      <apex:outputField value="{!contact.Contact_Status__c}"/>  
      <apex:outputField value="{!contact.reportsToId}">
      <apex:commandLink action="{!ViewOrgChart}" value="[{!$Label.conDetail_ViewOrgChart}]"/> </apex:outputField>
      <apex:outputField value="{!contact.LeadSource}"/> 
      <apex:outputText value=""/>
      <apex:outputField value="{!contact.Days_Since_Last__c}"/>
      <apex:outputField value="{!contact.accountId}" rendered="false"/>    
      <apex:outputField value="{!contact.mailingStreet}" rendered="false"/>
      <apex:outputField value="{!contact.mailingCity}" rendered="false"/>
      <apex:outputField value="{!contact.mailingState}" rendered="false"/>
      <apex:outputField value="{!contact.mailingPostalCode}" rendered="false"/>
      <apex:outputField value="{!contact.mailingCountry}" rendered="false"/>
      <apex:outputField value="{!contact.otherStreet}" rendered="false"/>
      <apex:outputField value="{!contact.otherCity}" rendered="false"/>
      <apex:outputField value="{!contact.otherState}" rendered="false"/>
      <apex:outputField value="{!contact.otherPostalCode}" rendered="false"/>
      <apex:outputField value="{!contact.otherCountry}" rendered="false"/>
   
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
</apex:page>

 basically whether i give values or not , whether the profile has permission or not the fileds placement should not change.

Thanks

Akhil

Alex.AcostaAlex.Acosta

Not sure if this will work, but have you tried to just wrap your values using <apex:PageBlockSectionItem>? Hopefully this will leave your alignment correct. Also at the PageBlockSection you can specify how many columns you'll like on the page.

mtbclimbermtbclimber

By default, just like in a page layout, when a user doesn't have field level security access to a field the result is other fields move, not that a blank is presented in it's place. If that's your goal you can try something like this:

 

<apex:page standardController="Account">
    <apex:pageBlock >
        <apex:pageBlockSection columns="2">
            <apex:outputField value="{!account.name}"/>
            <apex:pageblockSectionItem rendered="{!NOT($ObjectType.Account.Fields.Name.Accessible)}"/>
            <apex:outputField value="{!account.site}"/> 
            <apex:pageblockSectionItem rendered="{!NOT($ObjectType.Account.Fields.Site.Accessible)}"/>
            <apex:outputField value="{!account.industry}"/>  
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

 

SF7SF7

Thanks guys for your reply i will try these solutions.