function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bivhitscarbivhitscar 

Accessing parent field data

I'm going nuts and I know this is going to be something dead simple, but for some reason I can't work it out.

 

Signee__c is a Master-Detail to the Contact object. All I want to do is display the name from the contact record and at the moment it's just coming up blank. If I change the value in the repeat to a.Signee__c, I get the Id as expected. However I can't seem to access any actual data in the parent. I get no errors and I've been scouring google to work out what's wrong.

 

Ideas?

 

 

Extension:

 

public class SignOnExtension{
    ApexPages.StandardController controller;
    public SWMS_SignOn__c thisSignOn {get; set;}
    public List<SWMS_SignOn__c> attendees {get; set;}
    
    public SignOnExtension(ApexPages.StandardController c) {
        controller = c;
        thisSignOn = (SWMS_SignOn__c) controller.getRecord();
        attendees = new List<SWMS_SignOn__c>();
    }
    
    public void addSignee() {
        //create new signon and add to list
        attendees.add(new SWMS_SignOn__c(Signee__c = thisSignOn.Signee__c));
    }

}

 

 

Page:

 

<apex:page id="page" standardController="SWMS_SignOn__c" extensions="SignOnExtension" >
<apex:form id="form" >
<apex:pageBlock title="Add Attendee">
        <apex:pageBlockButtons location="bottom">
            <apex:commandButton action="{!addSignee}" value="Add" reRender="attendeesBlock"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection >
            <apex:inputField value="{!signOn.Signee__c}"/>
        </apex:pageBlockSection>
    </apex:pageBlock>

<apex:pageBlock title="Attendees" id="attendeesBlock"> <apex:pageBlockSection columns="1"> <apex:repeat value="{!attendees}" var="a"> <apex:pageBlockSectionItem > <apex:outputLabel >Attendee</apex:outputLabel> <apex:outputLabel value="{!a.Signee__r.Name}" /> </apex:pageBlockSectionItem> </apex:repeat> </apex:pageBlockSection> </apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

 

 

ericmonteericmonte

Better yet try this:

 

<apex:pageBlockSectionItem >
                    Attendee
                    <apex:outputText value="{!a.Signee__r.Name}" />
<!-- outputText doesnt work then use outPutField -->
</apex:pageBlockSectionItem>
bivhitscarbivhitscar

Neither outputText nor ouputField are working either - just display blank.

 

[edit]

To clarify, outputfield does give me the 'Name' label as would be expected, but the value area is blank.

ericmonteericmonte

Can you give me more background on your functionality?

 

Based on what I see here you have a standard controller to the SignOn__c object.

 

Then you have a pageBlock to add a Signee__c. I'm guessing this is either a Master Detail to the contacts, and you have an action button that reference to

 

    public void addSignee() {
        //create new signon and add to list
        attendees.add(new SWMS_SignOn__c(Signee__c = thisSignOn.Signee__c));
    }


but this method doesn't really do anything because you don't have  a DML statement.

 

Breaking down the code I'm really not sure what you are trying to implement.

 

Let me know what you want to do do and I'll help you out on it.

 

bivhitscarbivhitscar

It's basically a very simple attendance form. I want to build up a list of contacts (Signee__c) who are present at the 'Sign On' event and display the list. The end goal is to implement an html canvas in order to save handwritten signatures. So instead of passing a piece of paper around the room, we'll pass an iPad or some other touch device.

 

For page as it stands right now, the idea is to use the lookup field on the page to find a contact. Then press the Add button and the addSignee method should add a new instance of the SWMS_SignOn__c, using the current value of the Signee__c lookup field on the page. Rinse and repeat for all required contacts.

 

I think I'm starting to see why lack DML is relevant. Am I to assume the vf page won't dynamically retrieve related data?

ericmonteericmonte

Ahh i see what you are trying to do. That's what i thought you want.

 

I did an attendance form page similar to what you are trying to implement. Let me see if I can repurpose it for your needs.