1

How can I add multiple profiles to the below code? I get an error when I attempt to add more than one output panel that has showChatter="true". It errors with a message that says: Error: Only one Chatter-related component can be specified per page.

<apex:page standardController="Lead">

<apex:outputPanel rendered="{!$Profile.Name = 'System Administrator'}">
    <apex:detail subject="{!Lead.Id}" inlineEdit="true" showChatter="true"  /> </apex:outputPanel>

<apex:outputPanel rendered="{!$Profile.Name = 'Force'}" >
    <apex:detail subject="{!Lead.Id}" inlineEdit="true" showChatter="false"  /> </apex:outputPanel>

<apex:outputPanel rendered="{!$Profile.Name = 'Salesforce 44 Call Center'}" >
    <apex:detail subject="{!Lead.Id}" inlineEdit="true" showChatter="false"  /> </apex:outputPanel>

</apex:page>

I want to add more than one profile to the showchatter="true" output panel using a OR.

2
  • You should set the rendered property on the <apex:detail> tags themselves.
    – Adrian Larson
    Commented Sep 20, 2016 at 16:01
  • Could you give an example using the code above? I tried your instruction but I then get the following error: Error: The value of attribute "rendered" associated with an element type "apex:detail" must not contain the '<' character.
    – Blorg
    Commented Sep 20, 2016 at 16:04

2 Answers 2

4

You can use a || ('OR') statement inside the rendered tag:

<apex:page standardController="Lead">

<apex:outputPanel rendered="{!$Profile.Name = 'System Administrator' || $Profile.Name = 'Force' || $Profile.Name = 'Salesforce 44 Call Center'}">
    <apex:detail subject="{!Lead.Id}" inlineEdit="true" showChatter="{!$Profile.Name = 'System Administrator'}"  /> </apex:outputPanel>

</apex:page>
6
  • 2
    I think it should be showChatter="{!$Profile.Name = 'System Administrator'}".
    – Adrian Larson
    Commented Sep 20, 2016 at 16:09
  • 1
    You can do the same with the and operator && and not operator ! as well. About the only thing I'd try to avoid is having a 'not' be the first thing in an expression, because it's very easy to gloss over the second ! in {!!field__c} (or mistake it for double negation)
    – Derek F
    Commented Sep 20, 2016 at 16:09
  • @Derek That's the primary reason I tend to just use NOT, AND, and OR functions.
    – Adrian Larson
    Commented Sep 20, 2016 at 16:10
  • 1
    You are right @AdrianLarson, I overlooked the difference between the 3 panels. Not the first time you correct me ;-). Thanks! Commented Sep 20, 2016 at 16:11
  • @AdrianLarson Certainly an option. I personally find it harder to read Polish Notation than Infix notation though.
    – Derek F
    Commented Sep 20, 2016 at 16:15
0

Thanks to Guy!

I wanted to have two Output Panels, to easily track. One for Chatter True and One for Chatter False.

I used the following and this works too:

<apex:page standardController="Lead">

<apex:outputPanel rendered="{!$Profile.Name = 'System Administrator' || $Profile.Name = 'Customer Service' || $Profile.Name = 'Force Manager' || $Profile.Name = 'Manager'  || $Profile.Name = 'SuperUser'}" >
    <apex:detail subject="{!Lead.Id}" inlineEdit="true" showChatter="true"  />
</apex:outputPanel>

<apex:outputPanel rendered="{!$Profile.Name = 'Force' || $Profile.Name = 'Salesforce 44 Call Center'}" >
    <apex:detail subject="{!Lead.Id}" inlineEdit="true" showChatter="false"  />
</apex:outputPanel>

</apex:page>

You must log in to answer this question.

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