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
DoctorDoctor 

Event from Search Results

I have developed (with much appreciated forum help) a custom search app that allows a user to search Contacts based on up to four field values. Now that I have that peice working, I need to add on the functionality of being able to select multiple contacts from the search results and create an event for all of them in one hit.

 

Can someone point me in the right direction?

Keep in mind I am fairly new to all of this.

 

Thanks in advance.

 

 

rtuttlertuttle

How are the search results organized?  Are you sorting them into a multi select list?  Can you show an example code of your visualforce page where the result contacts are?

 

 

 

-Richard 

DoctorDoctor

Thanks for your reply. Please find below the extension code and the VF page code.

 

Extension Code:

public with sharing class contactSearchExtension { public contactSearchExtension(ApexPages.StandardSetController controller) { } public contactSearchExtension(ApexPages.StandardController controller) { } public String getName() { return null; } public String getState() { return null; } public List<Contact> result = new List<Contact>(); private String Name; private String State; public contactSearchExtension(){ } public List<Contact> getResult() { return result; } public void setName(String Name) { this.Name = Name; } public void setState(String State) { this.State = State; } public void search() { String queryName = Name + '%'; String queryState = State + '%'; if (Name == '' && State == ''){ result = [SELECT Account.Name, Name, MailingState, LastName FROM Contact ORDER by Account.Name, LastName]; } else if (Name != '' && State == ''){ result = [SELECT Account.Name, Name, MailingState, LastName FROM Contact WHERE Account.Name LIKE :queryName ORDER by Account.Name, LastName]; } else if (Name != '' && State != ''){ result = [SELECT Account.Name, Name, MailingState, LastName FROM Contact WHERE Account.Name LIKE :queryName AND MailingState like :queryState ORDER by Account.Name, LastName]; } else if (Name == '' && State != ''){ result = [SELECT Account.Name, Name, MailingState,LastName FROM Contact WHERE MailingState like :queryState ORDER by Account.Name, LastName]; } } }

 

 

VF Page:

 

<apex:page standardController="Contact" extensions="contactSearchExtension" id="page" cache="true" recordSetVar="unused" tabStyle="Event" showHeader="True" sidebar="True" title="Log Group Call"> <apex:form id="MassPanelUpdate"> <!-- Javascript Allows All Search Results to be Selected when Master Checkbox Checked or Deselect All Search Results when Master Checkbox Unchecked --> <script type="text/javascript"> function customSelectChecked(form, element_name, value) { var i = 0; for (i = 0; i < form.elements.length; i++) { if (form.elements[i].name.search('selected') > 0 && form.elements[i].disabled == false) { form.elements[i].checked = value; } } } function customSelectAllOrNoneByCheckbox(form, element_name, control) { customSelectChecked(form, element_name, control.checked); } </script> <apex:SectionHeader title="Log Group Call" /> <!-- Holds Search Criteria --> <apex:pageBlock > <apex:pageBlockSection title="Filter Criteria" columns="2"> <apex:pageBlockSectionItem >Account <apex:inputText value="{!Name}" /> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem >State <apex:inputText value="{!State}" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!search}" value="Search" id="searchBtn"/> </apex:pageBlockButtons> </apex:pageBlock> <!-- Display any Page Success or Error Messages --> <apex:pageMessages ></apex:pageMessages> <!-- Display Search Results --> <apex:pageBlock title="Search Results" id="Results"> <apex:dataTable value="{!result}" var="Contact" id="data" cellPadding="4" border="0" rowClasses="odd,even" onrowmouseout="if (window.hiOff){hiOff(this);}" onrowmouseover="if (window.hiOn){hiOn(this);}" width="400px"> <apex:facet name="caption"></apex:facet> <apex:facet name="header"></apex:facet> <apex:column width="20px" > <apex:facet name="header"> <!-- Allow All Search Results to be Selected when Checked or Deselect All Search Results when Unchecked --> <apex:inputCheckbox id="selectall" onclick="javascript:customSelectAllOrNoneByCheckbox(document.forms['Page:MassPanelUpdate'],'Page:MassPanelUpdate:Results:data:', this);" /></apex:facet> <!-- Show Selected Search Results and Allow to Select or Deselect any Results Individually --> <apex:inputCheckbox id="selected" /> </apex:column> <apex:column width="200px"> <apex:facet name="header"><u>Name</u></apex:facet> <a href="/{!Contact.Id}" target="_blank"><apex:outputField value="{!Contact.Name}" /></a> </apex:column> <apex:column width="200px"> <apex:facet name="header"><u>Account</u></apex:facet> <a href="/{!Contact.Account.Id}" target="_blank"><apex:outputField value="{!Contact.Account.Name}" /></a> </apex:column> <apex:column width="200px"> <apex:facet name="header"><u>State</u></apex:facet> <apex:outputField value="{!Contact.MailingState}" /> </apex:column> </apex:dataTable> </apex:pageBlock> </apex:form> </apex:page>