0

I have a field on a component for a VF page that I need to make read only for everyone unless they are listed in a picklist field(Project_Manager__c). I can see the usr value in the debug log so I know the usr value does not match the picklist value but the field stays editable. Is it because this is in a component and not on the actual VF page? What do I need to do to make this work?

 <apex:outputfield value="{!Project__c.Build_Year__c}">
      <apex:inlineEditSupport disabled="{!usr.Name != TEXT(Project__c.Project_Manager__c)}"/>
 </apex:outputfield>

Controller

  User usr = [SELECT ID, Name FROM User WHERE ID = :UserInfo.getUserId()];

2 Answers 2

1

Your Visualforce expression is invalid.

{{!usr.Name} != TEXT(Project_Manager__c)}

This is just text to the runtime. Visualforce expressions must start with {!. One possible valid form could be

{! usr.Name != TEXT(Project_Manager__c) }
6
  • Thanks for the reply. If I update the syntax I get this error 'Unknown property 'ProjectController.Project_Manager__c'. I am not referencing the Project_Manager__c field in the Controller.
    – Phuc
    Jun 15, 2020 at 15:12
  • Do I need to append !Project__c to the front of the Project_Manager__c field?
    – Phuc
    Jun 15, 2020 at 15:52
  • Just Project__c. No additional exclamation points.
    – David Reed
    Jun 15, 2020 at 16:12
  • Update my original question with the new syntax so that you can see. This gives the error :Incorrect parameter type for function 'TEXT()'. Expected Number, Date, DateTime, Picklist, received Text. So I removed the TEXT() and now the field is read only across the board.
    – Phuc
    Jun 15, 2020 at 16:31
  • Is it possible to have an if statement to render an output field if the user is listed in the picklist and if not have it render an output text? Right now its either always read-only or always editable.
    – Phuc
    Jun 17, 2020 at 14:09
0

'outputField' is read only by definition. I think you want an 'inputField' then tinker with the 'disabled' attribute via formulas

You must log in to answer this question.

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