1

Actually i want to create my custom visualforce page for community and want to rendered output field as per permission assignment for record type and Community profile.

<apex:page standardController="C_Object_Process__c" id="thePage"> 
    <apex:form id="theForm"> 
        <apex:pageBlock mode="inlineEdit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
                <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:outputField value="{!C_Object_Process__c  .name}">
                    <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                        hideOnEdit="editButton" event="ondblclick" 
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                </apex:outputField>
                <apex:outputField value="{!C_Object_Process__c.C_Item_SL_StudiedHours__c}"/>
                <apex:outputField value="{!C_Object_Process__c.C_Item_TR_AdditionalDocument__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

I don't want to show field "C_Item_TR_AdditionalDocument__c" if this is not in standard page layout for a certain record type

Thanks in Advance!

  • Please share some code. – Shailesh Patil Jun 10 '16 at 7:13
  • Hi Shailesh i have edited with sample code have look please – kumar gaurav Jun 10 '16 at 7:37
  • Hi Kumar, Sorry for the delayed response. I found your question pretty curious. I have few more questions: 1) Is the page an inline VF page? 2) If I am not wrong, you want to get the information about the field's accessibility on page layout. Meaning, the field is accessible via profile to the user but not through pageLayout. For e.g. User A has profile ABC which has access to field A__c. But the field is hidden on pageLayout. Please correct me if I am wrong. – Shailesh Patil Jun 10 '16 at 16:52
0

It appears to me that you're going to need to use Global Variables and probably a Controller Extension to do what you're asking. If you look at Checking for Object Accessibility in the VF Reference, you'll find code like the following:

<apex:page standardController="Lead">
    <apex:pageBlock rendered="{!$ObjectType.Lead.accessible}">
        <p>This text will display if you can see the Lead object.</p>
    </apex:pageBlock>
    <apex:pageBlock rendered="NOT({!$ObjectType.Lead.accessible})">
        <p>Sorry, but you cannot see the data because you do not have access to the Lead object.</p>
    </apex:pageBlock>
</apex:page> 

You can use the above type of code to conditionally render based on a user's access to an object. However, you're wanting to go beyond that to the record level and even further to the recordType.

You can get a User's profile Id or profile name using $Profile.Id and $Profile.Name respectively. Under normal sharing rules, not all profiles will have edit capabilities to all RecordTypes. However, they'll normally still have ReadOnly access to them. So, that's where this will get challenging for you.

You'll likely need to create a Controller Extension that checks for the RecordType and compares it to the permission for the Profile to decide whether or not to display the record. Based on the results of that, you can then decide whether or not to render the fields in your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.