2

I have provided standard inline edit functionality on the visualforce page. I want to restrict the user to edit the field if he/she has not edit access on it. I have set FLS as read only for these fields. Still I can edit this field and able to save the new value. Standard contoller for the page is 'Account' and extention class is 'with sharing' keyword.

    <apex:page standardStylesheets="false" showHeader="false" sidebar="false" standardController="Account" extensions="AMSocketController">
    </apex:page>

Apex Class is:

public with sharing class AMSocketController{
 //Constructor
    public AMSocketController(Apexpages.Standardcontroller stdController) {

}

}

How to restrict read only field on visualforce page to edit using Inline edit functionality?

Thank you In advance.

1

Use apex:inputField only to apply FLS.

VisualForce will also remove fields for which users do not have FLS visibility when rendering edit pages. Additionally, all apex:inputField tags will be rendered as read-only elements for fields that are set to read-only through FLS. Please note that using other input tags such as apex:inputText or apex:inputTextArea with SObject fields indicate to VisualForce that the fields should not be treated as SObject fields and prevent the platform to automatically enforcing FLS.

  • I am facing the problem for this code : <apex:outputField value="{!account.of_MDs_using_Coordinator_Core__c}"> <apex:inlineEditSupport event="ondblclick" showOnEdit="update"/> </apex:outputField> – pornima Jun 24 '16 at 12:08
  • 1
    If you have restricted the field through FLS then page will show you error insufficient privilege while saving the record. Is it happening in your case ? – MIX DML Jun 24 '16 at 13:04
  • I was able to edit read-only field because of 'system admin' profile has system permission 'Edit Read Only Fields' and it is by default on. – pornima Jun 27 '16 at 12:22
0

You can have two elements for a particular field for Example:

(This isVisible should be checked in the controller whether the user can edit or not)

<apex:outputField value="{!x.somefield__c}" rendered={!isVisible}/>

AND

<apex:inputFiled value="{!x.somefield__c}" rendered={!isVisible}/> 

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.