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.

2 Answers 2

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.

3
  • 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
    Commented Jun 24, 2016 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
    Commented Jun 24, 2016 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
    Commented Jun 27, 2016 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}/> 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .