• Dwain Bowman
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Data and Insight Manager

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I am trying to add a button to a related list called "Confirm Attendance".The button should open a visual force page containing records related to the record on the page.

At the moment, the only way I can get this to work is by using <apex:pageBlockTable value="{!selected}" ... Row 9. The user has to click on "view all", then "select all", then click the button "confirm register",  use input check box {!reg.Registered__c} and then click save.  
 
<apex:page standardController="Participation_Data__c" recordSetVar="participation" >
   <apex:form >
      <apex:pageBlock title="Confirm Attendance" mode="inlineEedit">
         <apex:pageMessages />
         <apex:pageBlockButtons location="bottom">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
         </apex:pageBlockButtons> 
         <apex:pageBlockTable value="{!selected}" var="reg">
            <apex:column value="{!reg.Participant_Registered__c}" />
            <apex:column value="{!reg.Event__r.Session_Name__c}" />
            <apex:column value="{!reg.Event__r.Start_Date__c}" />
            <apex:column headerValue="Registered?">
               <apex:inputField value="{!reg.Registered__c}"/>
            </apex:column>
 
         </apex:pageBlockTable>
      </apex:pageBlock>
   </apex:form>
</apex:page>

I would like to button to get the id from URL, finds the related list where reference ID = URL, then populates pageblocktable as records for value="{!selected}" .

Thank you in advance.

 
I am attempting to create a simple register "app" for a small sports charity.

Key Objects 
1Contact
2Participation_Events__c
3Participation_Data__c (junction between 1 and 2)

However, I would like to use another Junction (Participant_Group for example), so users can create groups and add multiple contacts to one event at a time - plus store that data in the pre mentioned junction  (3Participation_Data__c)

Additional Objects
4)Group_at_Session__c (lookup between 2 and 6)
5)Participant_Group_Member__c (junction between 1 and 6)
6)Participant_Group__c (information about the group)

Process
Create Contacts
Create Groups
Create Event, add group via lookup
system
- take lookup group and add group to the group_at_session junction (working fine)
- find contact ids in group (seems to be working)
- create new junction records with loop (not working)
- remove lookup value from the new Event record (not working)

There is a bunch of logic on the Participation_Events__c object, it may not make complete sense to do it this way, but the event seems to be the main focal point for the org. 

Here is the code, please take a look. 
 
trigger AddGroupToSession on Participation_Events__c (after insert, after update) {
    for(Participation_Events__c session : Trigger.new) {
        //if(trigger == before update)    
        //  session.Participant_Group__c = null;
        
        if (session.Participant_Group__c != null)
        {
            
            Group_at_Session__c sgroup = new Group_at_Session__c();
            
            sgroup.Sessions__c= session.id;
            sgroup.Participant_Group__c= session.Participant_Group__c;
            
            insert sgroup;
            
            ID groupId = session.Participant_Group__c; 
            
            system.debug('groupId - '+groupId);  
            
            
            list<Participant_Group_Member__c> contactIds = 
                [SELECT Contact__c
                 FROM Participant_Group_Member__c 
                 WHERE Crew_Name__c = :groupId 
                 //Limit 1
                ];            
            
            system.debug('contactIds 1st - '+contactIds.get(0));
            system.debug('contactIds last - '+contactIds[contactIds.size()-1]);
            system.debug('contactIds count - '+contactIds.size());                
            
            if(session.Register_Group__c == true){   
                for(integer i = 0; i < contactIds.size(); i++)  {
                    
                    Participation_Data__c obj = new Participation_Data__c(); 
                    
                    obj.Event__c = session.Id; 
                    obj.Participant_Registered__c= contactIds.get(i);
                    obj.Registered__c=TRUE;
                    
                    insert obj;
                    system.debug('Register = True - '+obj); 
                }
            }
            else{                
                for(integer i = 0; i < contactIds.size(); i++)  {
                    
                    Participation_Data__c obj = new Participation_Data__c(); 
                    
                    obj.Event__c = session.Id; 
                    obj.Participant_Registered__c= contactIds[i];
                    obj.Registered__c=FALSE;
                    
                    insert obj;
                    system.debug('Register = False - '+obj); 
                }
            }   
        }
    }
}



I keep getting the same error; I was hoping someone could help. Error message: "Illegal assignment from Participant_Group_Member__c to Id", which occurs on lines (38,51). However, the system.debug shows that the correct Contact Ids are being pulled by the SOQL query, so I am a bit confused. This is my first attempt at coding, so please explain where I've gone wrong.

Thank you in advance!


 
I am attempting to create a simple register "app" for a small sports charity.

Key Objects 
1Contact
2Participation_Events__c
3Participation_Data__c (junction between 1 and 2)

However, I would like to use another Junction (Participant_Group for example), so users can create groups and add multiple contacts to one event at a time - plus store that data in the pre mentioned junction  (3Participation_Data__c)

Additional Objects
4)Group_at_Session__c (lookup between 2 and 6)
5)Participant_Group_Member__c (junction between 1 and 6)
6)Participant_Group__c (information about the group)

Process
Create Contacts
Create Groups
Create Event, add group via lookup
system
- take lookup group and add group to the group_at_session junction (working fine)
- find contact ids in group (seems to be working)
- create new junction records with loop (not working)
- remove lookup value from the new Event record (not working)

There is a bunch of logic on the Participation_Events__c object, it may not make complete sense to do it this way, but the event seems to be the main focal point for the org. 

Here is the code, please take a look. 
 
trigger AddGroupToSession on Participation_Events__c (after insert, after update) {
    for(Participation_Events__c session : Trigger.new) {
        //if(trigger == before update)    
        //  session.Participant_Group__c = null;
        
        if (session.Participant_Group__c != null)
        {
            
            Group_at_Session__c sgroup = new Group_at_Session__c();
            
            sgroup.Sessions__c= session.id;
            sgroup.Participant_Group__c= session.Participant_Group__c;
            
            insert sgroup;
            
            ID groupId = session.Participant_Group__c; 
            
            system.debug('groupId - '+groupId);  
            
            
            list<Participant_Group_Member__c> contactIds = 
                [SELECT Contact__c
                 FROM Participant_Group_Member__c 
                 WHERE Crew_Name__c = :groupId 
                 //Limit 1
                ];            
            
            system.debug('contactIds 1st - '+contactIds.get(0));
            system.debug('contactIds last - '+contactIds[contactIds.size()-1]);
            system.debug('contactIds count - '+contactIds.size());                
            
            if(session.Register_Group__c == true){   
                for(integer i = 0; i < contactIds.size(); i++)  {
                    
                    Participation_Data__c obj = new Participation_Data__c(); 
                    
                    obj.Event__c = session.Id; 
                    obj.Participant_Registered__c= contactIds.get(i);
                    obj.Registered__c=TRUE;
                    
                    insert obj;
                    system.debug('Register = True - '+obj); 
                }
            }
            else{                
                for(integer i = 0; i < contactIds.size(); i++)  {
                    
                    Participation_Data__c obj = new Participation_Data__c(); 
                    
                    obj.Event__c = session.Id; 
                    obj.Participant_Registered__c= contactIds[i];
                    obj.Registered__c=FALSE;
                    
                    insert obj;
                    system.debug('Register = False - '+obj); 
                }
            }   
        }
    }
}



I keep getting the same error; I was hoping someone could help. Error message: "Illegal assignment from Participant_Group_Member__c to Id", which occurs on lines (38,51). However, the system.debug shows that the correct Contact Ids are being pulled by the SOQL query, so I am a bit confused. This is my first attempt at coding, so please explain where I've gone wrong.

Thank you in advance!