0

I’m experiencing a strange issue with a Custom Object that I’ve frankly never come across before. I have a VF page that is not able to display the value from a specific Lookup object field. Other Lookup object fields are no problem.

The confounding issue - that may or may not be related - is that, for some unknown reason, I have to access the fields on this object using a array index notation (e.g. [0]) in order for it to compile.

Here’s a pared down test case I put together to illustrate the issue

VF Page:

<apex:page controller="TestCaseController">
    <apex:define name="body">
        <apex:repeat value="{!opps}" var="opp">
            <apex:outputText rendered="{!opp.Name == 'Name of Test Opp'}">
                <p>Good Custom Object Name: {!opp.Good_Custom_Object__r.Name}; Id: {!opp.Good_Custom_Object__c}</p>
                <p>Not Working Custom Object Name: {!opp.Not_Working_Custom_Object__r[0].Name}; Id: {!opp.Not_Working_Custom_Object__c}</p>
            </apex:outputText>
        </apex:repeat>
    </apex:define>
</apex:page>

TestCaseController:

public without sharing class TestCaseController {
    public List<Opportunity> getOpps() {
        return [SELECT Name, Good_Custom_Object__r.Name, Not_Working_Custom_Object__r.Name FROM Opportunity WHERE Id = 'testOppIdThatIKnowHasValuesInBothLookupFields'];
    }
}

The output of the page I get is:

Good Custom Object Name: Name of Good Custom Object Record; Id: IdofGoodCustomObjectRecord

Not Working Custom Object Name: ; Id: IdofNotWorkingCustomObjectRecord

As you can see, the Name of the second custom object simply does not display (nor does any other field I’ve tried including from that object).

Other things to know:

  1. If I remove the [0] when referencing the name of the not working object I get the compile time error: Unknown property 'VisualforceArrayList.Name'
  2. I’m accessing the page as a Partner User via a Site
  3. The test VF Page has been included in the Site
  4. If I access the page via /apex/ as an Admin, the Name value is present for both objects
  5. The FLS settings are the same (View, Edit) for the Good and Not Working Lookup fields for the Partner User Profile on the Opp
  6. The FLS settings are the same (View, Edit) for the Good and Not Working Name fields
  7. The Profile has the same settings (Read, Edit) in the Custom Object Permissions
  8. I tried adding true to the Not Working custom object definition, but that seemed to have no effect
  9. The External Sharing Models for both objects are set to Private
  10. The recent Guest User Sharing security updates have not been applied in my org

As you might imagine, this is driving me a bit mad. Any help figuring this out will be met with extreme gratitude :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.