0

I've created a Visualforce page and I want a record to render as an inputfield for certain profiles. Can someone help me with the Profile Id syntax?

The following works if I remove the following: {!$Profile.Id} = '00ec0000000Htxe'

However, if I add it, it gives me the following error: 'Save error: Syntax error'

4
  • Can you please be more specific about what you want to accomplish, and what you have tried so far?
    – Adrian Larson
    Sep 30, 2016 at 20:16
  • This is what I have. It works when I remove '{!$Profile.Id} = '00ec0000000Htxe'} ' <apex:inputField value="{!i.Answer_Text__c}" style="width:80%" rendered="{!IF(AND(i.Status__c!='Submitted', i.Question__r.Type__c == 'Text', {!$Profile.Id} = '00ec0000000Htxe'} ), 'true', 'false')}" />
    – Leslie
    Sep 30, 2016 at 20:17
  • And what's wrong with that? Please edit your post with any updates rather than crowding them into the comments section.
    – Adrian Larson
    Sep 30, 2016 at 20:17
  • I get the following error: 'Save error: Syntax error'
    – Leslie
    Sep 30, 2016 at 20:21

1 Answer 1

2

Several issues:

  • You don't need to use merge field within a merge field.
    • This issue is what's causing your expression to break.
  • Don't hard-code Ids, use $Profile.Name instead.
  • You can always simplify IF(condition, true, false) to just condition.

Incorrect

rendered="{!AND({!$Profile.Id}='<id_here>', /*other clauses here*/)}"

Correct

rendered="{!AND($Profile.Name='<profile_name_here>', /*other clauses here*/)}"
2
  • This is the old-school way of doing it. Today, I'd recommend a custom permission for additional versatility.
    – sfdcfox
    Sep 30, 2016 at 20:34
  • Yes, that is a great way to whitelist users and preferable to other options in many cases. We have so little context here, it is hard to recommend that route specifically.
    – Adrian Larson
    Sep 30, 2016 at 20:35

You must log in to answer this question.

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