1

I have two objects. Package__c and Transfer__c, and Package__c is a child of Transfer__c. They both have their fieldsets that I have made. What I want is to access the fieldset of Transfer__c while the standardcontroller is set to Package__c. But I get "unknown property string". Here is what I have:

<apex:page standardController = 'Package__c' >
<apex:form>
    <apex:pageBlock>
        <apex:pageBlockSection title='Package Information'>
            <apex:repeat value='{!$ObjectType.Package__c.FieldSets.Info}' var = 'f'>
                <apex:outputField value='{!package__c[f]}'/><br/>
            </apex:repeat>
        </apex:pageBlockSection>
    </apex:pageBlock>
    <apex:pageBlock>
        <apex:pageBlockSection title='Transfer Information'>
            <apex:repeat value='{!Package__c.Transfer__c}' var = 'transfer'>
                <!--<apex:outputField value='{!Package__c[f]}'/><br/>-->
                <apex:repeat value='{!$ObjectType.Transfer__c.FieldSets.Label}' var ='lb'>
                    <apex:outputField  value="{!Package__c.Transfer__c.[lb]}"/>
                </apex:repeat>
            </apex:repeat>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

1 Answer 1

0

The syntax for your child records looks a bit off. Do you know the Child Relationship Name for the lookup from the child to parent? If you go to the lookup field on the child object in Salesforce Setup, it will display what the Child Relationship Name is. You need to use this for your child list. Eg.

<apex:pageBlockSection title='Transfer Information'>
    <apex:repeat value='{!Package.Transfers__r}' var='transfer'>
        <apex:repeat value='{!$ObjectType.Transfer__c.FieldSets.Label}' var ='lb'>
            <apex:outputField  value="{!transfer[lb]}"/>
        </apex:repeat>
    </apex:repeat>
</apex:pageBlockSection>
4
  • So I looked up the package fields and relationship. In the field for transfer the API name is "Transfer__C" and data type is "Lookup(Transfer). So I think I have it correct? Unless I am looking at the wrong place? Commented Jan 25, 2018 at 21:51
  • Wrong place. Click on the field itself and it'll take you to the details of that lookup field. There is a field on that screen called "Child Relationship Name". Take that value and append __r in your VisualForce page to get the Child Relationship Name to use. Commented Jan 25, 2018 at 22:16
  • Actually, you're saying Package__c is a child of Transfer__c? Then go to the Transfer__c field on the Package__c object and you'll see it there. It'll most likely be called Transfer or Transfers if you haven't changed it, meaning the relationship name is Transfer__r or Transfers__r. Commented Jan 25, 2018 at 22:17
  • And in saying that, I'm confused about your page. Your parent object should be the standardController (so Transfer__c), and your page should be iterating over the child Payment__c records. You have it the wrong way around. Commented Jan 25, 2018 at 22:19

You must log in to answer this question.

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