0

When I try to use in VisualForce page apex variable which references hierarchy custom setting, it is possible to save the page but it is not possible to deploy that page to production or another sandbox or organization.

<apex:page >
<apex:variable var="isAdmin" value="{!CONTAINS($Profile.Name, 'System Administrator')}" />
<apex:variable var="profileWasGivenAccess" value="{!CONTAINS($Setup.SomeHierarchyCustomSetting__c.CommaSeparatedListOfProfileIds__c,$Profile.Id)}" />
<apex:outputPanel rendered="{!isAdmin}">
X<br/>
</apex:outputPanel>
=== Text between X and Y ===<br/>
<apex:outputPanel rendered="{!OR(profileWasGivenAccess,isAdmin)}">
Y<br/>
</apex:outputPanel>
=== Text between Y and Z ===<br/>
<apex:outputPanel rendered="{!OR(profileWasGivenAccess,isAdmin)}">
Z
</apex:outputPanel>

</apex:page>

Does anyone knows a workaround for this?

Should I open a Salesforce support case for this?

Or should I add idea to IdeaExchange for salesforce to fix this?

Deployment error message is following:

*********** DEPLOYMENT FAILED ***********
Request ID: 0AfE000000SoMe_Id

All Component Failures:
1.  pages/var.page -- Error: Unknown property 'profileWasGivenAccess' referenced in var

*********** DEPLOYMENT FAILED ***********
0

Ok... Looks like I have found a workaround for this...

If I refactor my page as following and try to deploy it works...

<apex:page >
<apex:variable var="isAdmin" value="{!CONTAINS($Profile.Name, 'System Administrator')}" />
<apex:variable var="display" value="{!OR(CONTAINS($Setup.SomeHierarchyCustomSetting__c.CommaSeparatedListOfProfileIds__c,$Profile.Id),isAdmin)}" />
<apex:outputPanel rendered="{!isAdmin}">
X<br/>
</apex:outputPanel>
=== Text between X and Y ===<br/>
<apex:outputPanel rendered="{!display}">
Y<br/>
</apex:outputPanel>
=== Text between Y and Z ===<br/>
<apex:outputPanel rendered="{!display}">
Z
</apex:outputPanel>

</apex:page>

Not sure if I open a case against Salesforce support, probably, not. However, this is an issue and there might be a reason to post to IdeaExchange idea to fix that issue. However, they never pay attention to ideas which do not reach threshold, not sure if I post idea to fix this on IdeaExchange...

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.