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
venkateshyadav1243venkateshyadav1243 

One Event for multiple Contacts

Hi

I need to assigen one event to mutliple contacts in my vf page

my scenario is :in the vf page if i select add(button) to enter the event details

I have one more button 'add contacts',

in the click of that button i have to select some contacts

 

If i save the records,i have to assigen that event to the all the selected contact.

 

here i write the vf page and class ,in my code only the first one inserting but it not assigening the multiple contacts.

 

 

this is the vf page


<apex:page standardController="Contact" extensions="ADD_Showings_To_Contact">
<apex:form >
<apex:pageBlock >
 <apex:commandLink value="Add New Showing" action="{!addshwoing}"  />
  <apex:pageBlockTable value="{!ev}"  var="e">
<apex:column headerValue="Subject">
        <apex:inputField value="{!e.Subject}"/>
        
    </apex:column>
    
    <apex:column headerValue="Name" >
        <apex:inputField value="{!e.WhoId}" />
    </apex:column>
    <apex:column headerValue="Start Date Time">
        <apex:inputField value="{!e.StartDateTime}"/>
    </apex:column>
    <apex:column headerValue="End Date Time">
        <apex:inputField value="{!e.EndDateTime}"/>
    </apex:column>
    <apex:column headerValue="Location">
        <apex:inputField value="{!e.Location}"/>
    </apex:column>
    
    <apex:column headerValue="Summary">
        <apex:inputField value="{!e.Summary__c}"/>
    </apex:column>
    
    <apex:column headerValue="Description">
        <apex:inputField value="{!e.Description}"/>
    </apex:column>
    
</apex:pageBlockTable>
<apex:commandLink value="Add New Contact" action="{!addnewcontact}"  />
 <apex:pageBlockTable value="{!evt}"  var="et" rendered="{!addshwoingcntbtn}">
 <apex:column headerValue="Name" >
        <apex:inputField value="{!et.WhoId}" />
    </apex:column>
    </apex:pageBlockTable>

<apex:pageblockSection columns="1" >
       <apex:pageblockSectionItem >
                <apex:commandButton action="{!addshowingsavemethod}" id="saveButton" value="Save" />
                
                     </apex:pageblockSectionItem>
            </apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>




this is my class



public class ADD_Showings_To_Contact {
public id conid{get;set;}
Contact con =new contact();
public list<Event> ev{get;set;}
public list<Event> evt{get;set;}
public event  addevent{get;set;}
public boolean addshwoingbtn{get;set;}
public boolean addshwoingcntbtn{get;set;}

    public ADD_Showings_To_Contact(ApexPages.StandardController controller) {
 conid= apexpages.currentpage().getparameters().get('id');
   con=[SELECT AccountId,stage__c,name,Email,Phone from contact where id=:conid];
         ev=new list<Event>();
                ev=[select WhatId,Subject,StartDateTime,Location,EndDateTime,Description,ShowAs from event where WhoId=:conid];
                 evt=new list<Event>();
evt=[select WhatId,Subject,StartDateTime,Location,EndDateTime,Description,ShowAs from event where WhoId=:conid];
    }
    public void addshwoing()
    {
 
       ev.add(new event());      
    }
    
     public void addnewcontact()
    {
    evt.add(new event());
    addshwoingcntbtn=true;
    }
     public pagereference addshowingsavemethod()
    {
    try{
     insert ev;
     insert evt;
        system.debug('insert the addevent records'+ev);
        system.debug('insert the addeventsss records'+evt);
        ev=null;
        evt=null;
        }
        catch(Exception e)
        {system.debug(e);}
         pagereference pr=new pagereference('/apex/opportunitytab?id=conid');
    return pr;
        }
}

 

 

Can one help me

Thanks to advance.

 

 

venkatesh.

bvramkumarbvramkumar

You can not assign one event to multiple contacts in you requirement for sure because the contacts and the number of contacts you have to select are dynamic.

 

The solution is to create the event for each of the contacts you selected. Suppose, if you have selected 4 contacts, you need to create 4 events (with the same details you entered) - each assigned to each of the contacts.

venkateshyadav1243venkateshyadav1243

Hi

Thanks

For your replay

Can you tel me the how can i assigen the same detials to all contacts

 

 

Regards

venkatesh