I have 3 objects - Contact(Master), Volunteer(Junction), Event(Master) and want to display fields from the Volunteer and Event objects on a VisualForce Page for a Communities User. An Event can have many Contacts (via Volunteer), and a Contact can have many Events (via Volunteer).

I want a My Events page that will display all the Events for a specific Communities user (who also has a respective Contact Record). I am able to get all of the Event data to show but the only fields that will show for the Volunteer object are the Master Detail look up Ids to Contact and Event.


    public myWorkshops(ApexPages.StandardController stdController) {
    users = [SELECT Id, ContactId FROM User WHERE Id =:userId];

    if (users.size() > 0) {
        userCon = users[0].ContactId;

    //All Workshops
    eventsCount = [Select Id, Event_Status__c,  Start_Date1__c, RecordTypeId 
                  From Event__c
                  Where RecordTypeId IN (Select Id from RecordType Where Name = 'Workshop') and Event_Status__c = 'Scheduled' and  Start_Date1__c >= TODAY ];


    myNSVs = [Select Id, Workshop__c, Contact__c, Contact_Name__c, Contact_Email__c,  Workshop_Application__c, Assignment_Status__c, Workshop_Role__c, Workshop_Attendance__c
             From Non_Stipend_Volunteers__c
             Where Workshop__c IN :eventsCount and Contact__c =: userCon and Assignment_Status__c != 'Cancelled'];

            system.debug('My NSVs++++'+myNSVs.size());                

    set<Id> eventIdsNSV = new set<Id>();
    for (Non_Stipend_Volunteers__c v: myNSVs) {

            nummyNSVs = myNSVs.size();
            system.debug('My NSVs Workshops Count++++'+nummyNSVs);

            eventsNSV = [Select Id, Name, Event_Type__c, Event_Status__c,  Start_Date1__c, End_Date1__c, College_Host__c, RecordTypeId, College_Host_Text__c,
              Location__c, Location_Address__c, Location_City__c, Location_State__c, Location_Postal_Code__c, Region__c,
              Comments__c, Published__c, Directions__c, 
              (Select Workshop__c, Contact__c, Workshop_Application__c, Assignment_Status__c, Workshop_Attendance__c, Workshop_Role__c From NSV_Workshops__r)
              From Event__c
              Where RecordTypeId IN (Select Id from RecordType Where Name = 'Workshop') and Event_Status__c = 'Scheduled'  and Start_Date1__c >= TODAY and Id IN: eventIdsNSV
              order by Start_Date1__c];


  <apex:page sidebar="false" standardController="Event__c"     extensions="myWorkshops" tabStyle="My_Workshops__tab">
  <apex:form >
 <apex:messages />
<apex:sectionHeader title="My Workshops!"/>
<apex:repeat value="{!eventsNSV}" var="n" >
<apex:pageBlock >
    <apex:pageBlockSection title="{!n.Name}" >
        <apex:outputPanel rendered="{!nummyNSVs != 0}">
            <apex:outputLabel style="font-weight:bold;font-style:italic;">When:</apex:outputLabel><br/>
            <apex:outputText value="{0,date,MM/dd/yyy}" ><apex:param value="{!n.Start_Date1__c}"/></apex:outputText><apex:outputText >  -  </apex:outputText><apex:outputText value="{0,date,MM/dd/yyy}" ><apex:param value="{!n.End_Date1__c}"/></apex:outputText><br/><br/>
            <apex:outputLabel style="font-weight:bold;font-style:italic;">Where:</apex:outputLabel><br/>
            <apex:outputLabel rendered="{!n.College_Host_Text__c != null}">{!n.College_Host_Text__c}<br/></apex:outputLabel>
            <apex:outputLabel rendered="{!IF(ISBLANK(n.Location_Address__c),false,true)}">{!n.Location_Address__c}<br/></apex:outputLabel> 
            <apex:outputLabel rendered="{!IF(ISBLANK(n.Location_City__c),false,true)}">{!n.Location_City__c},</apex:outputLabel>
            <apex:outputLabel >{!n.Location_State__c}</apex:outputLabel>
            <apex:outputLabel rendered="{!IF(ISBLANK(n.Location_Postal_Code__c),false,true)}">{!n.Location_Postal_Code__c}</apex:outputLabel><br/><br/>
            <apex:outputLabel style="font-weight:bold;font-style:italic;">Directions:</apex:outputLabel><br/>
            <apex:outputLabel >{!n.Directions__c}</apex:outputLabel>
            <apex:outputLabel rendered="false">{!n.Id}</apex:outputLabel>
    <div align="center">
         <apex:commandLink coords="left-x, top-y, right-x, bottom-y" styleClass="btn" style="text-decoration:none;padding:4px;" shape="rect"  value="Cancel Registration">
             <apex:param name="eventId" value="{!n.Id}" assignTo="{!eventParam}"/>

When I try to leverage {!n.NSV_Workshop__r.Workshop__c} I get "Error: Unknown property 'VisualforceArrayList.Workshop_Role__c'" When I add in [0] !n.NSV_Workshop__r[0].Workshop_Role__c I get a blank output and if I remove the field and just put !n.NSV_Workshop__r[0] I get the ID of the Junction Object to render.

I am losing my mind! PLEASE SOMEONE HELP!

1 Answer 1


The query that populates eventsNSV includes the relationship field NSV_Workshops__r that represents a collection of objects (zero or more). So I suggest you add something like this to get an idea of what is going on:

<apex:outputPanel rendered="{!nummyNSVs != 0}">
    <apex:repeat value="{!n.NSV_Workshops__r}" var="w">
        XXX <apex:outputText value="{!w.Workshop_Role__c}"/> YYY

If all you see in the output is


then the child query returned no rows; if you see


then there are rows but they have empty Workshop_Role__c fields.

You must log in to answer this question.

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