You need to sign in to do that
Don't have an account?
ckellie
Current Picklist value for each Record
i have a status picklist with different statuses for each campaign. while i only want to see the picklist values associated with the campaign member's campaign, I also want to see the current picklist value for each record / campaign member. Currently all of the listed campaign member statuses are set to sent, the default value. How do I change this.
Here is the code controlling the picklist values:
public List<SelectOption> getcStatus(){ List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption(campaignmember[0].status, campaignmember[0].status)); for(CampaignMemberStatus ccm:[select id, Label from CampaignMemberStatus where Campaignid in (select campaignid from CampaignMember where Campaign_Name__c =:selectedcval) and Label != :statusupdate]){ options.add(new SelectOption(ccm.id, ccm.label)); } return options; }
Here is the complete apex class:
public with sharing class CampaignListOwner13{ public CampaignListOwner13() { } List<SelectOption> selectedOwnerList = new List<SelectOption>(); Map<id, String> mappingval = new Map<id, String>(); Map<String, String> mappingcval = new Map<String, String>(); Map<String, String> mappingsval = new Map<String, String>(); public Map<String, String> localCStatusMap; public String selectedval { get; set;} public String selectedcval { get; set;} public String selectedsval { get; set;} public string statusval { get; set;} public string statusUpdate {get; set;} public string campaignStatus {get; set;} public CampaignListOwner13(ApexPages.StandardController controller) { } public String getCampaign() { return this.Campaign; } public String getCampaignStatus() { return this.CampaignStatus; } public string s; public String campaign; public transient string Campaignid{ get; set;} private transient CampaignMember[] members; //the members for that campaign public transient String owner; //owner ID public string getOwner() { return this.owner; } public void setOwner(String s) { this.Owner = s; } public List<CampaignMember> CampaignMember { get; set;} public List<SelectOption> getselectedOwner(){ List<SelectOption> optionList = new List<SelectOption>(); optionList.add(new SelectOption( '1', 'SELECT' )); for(User u:[select id,name from user where id in (select ownername__c from campaignmember) order by name]) { optionList.add(new SelectOption(u.id, u.name)); mappingval.put(u.id, u.name); } return optionList; } public List <SelectOption> getcampaignlists(){ system.debug('SFDC TEST ************ OWNER' + Owner); system.debug('SFDC TEST1 *************' + selectedVal); AggregateResult[] groupedResults = [select Campaignid , Campaign_Name__c from campaignmember where ownername__c=:selectedval group by Campaignid, Campaign_Name__c ]; List <SelectOption> optionList = new list<SelectOption>(); optionList.add(new SelectOption( '1', 'SELECT' )); system.debug('SFDC TEST2 *************' + selectedVal); if(selectedcval!= null){ for(Aggregateresult ar :groupedResults) { optionList.add(new SelectOption(String.valueof( ar.get('Campaign_Name__c')), String.valueof(ar.get('Campaign_Name__c')))); String aID = (string)ar.get('Campaign_Name__c'); mappingcval.put(aID, aID); } } return optionList; } public List <SelectOption> getstatuslist(){ system.debug('SFDC TEST ************ OWNER' + Owner); system.debug('SFDC TEST3 *************' + selectedVal); AggregateResult[] groupedResults = [select Status from campaignmember where ownername__c=:selectedval and Campaign_Name__c=:selectedcval group by Status ]; List <SelectOption> optionList = new list<SelectOption>(); optionList.add(new SelectOption( '1', 'SELECT' )); system.debug('SFDC TEST4 *************' + selectedVal); system.debug('SFDC TESTold *************' + selectedVal); if(selectedval!= null){ for(Aggregateresult ar :groupedResults) { optionList.add(new SelectOption(String.valueof( ar.get('Status')), String.valueof(ar.get('Status')))); String sID = (string)ar.get('Status'); mappingsval.put(sID, sID); } } return optionList; } public List<SelectOption> getcStatus(){ List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption(campaignmember[0].status, campaignmember[0].status)); for(CampaignMemberStatus ccm:[select id, Label from CampaignMemberStatus where Campaignid in (select campaignid from CampaignMember where Campaign_Name__c =:selectedcval) and Label != :statusupdate]){ options.add(new SelectOption(ccm.id, ccm.label)); } return options; } public PageReference campaignRefresh() { system.debug('$$$$$:'+selectedcval); system.debug('SFDC TEST5 *************' + selectedVal); system.debug(mappingval.get(selectedval)); system.debug('SFDC TEST6 *************' + selectedVal); try { if( selectedval != '1'){ CampaignMember = [select Id, owner_Name__c, Campaign_Name__c, ContactId, LeadId, Status, Lead.Lead_Salutation_Name__c, Country__c, CampaignId, Campaign.Name, Company__c, Lead.Id, Lead.Salutation, Lead.Title, Lead.Name, Lead.Company, Lead.Phone, Lead.Street, Lead.State, Lead.PostalCode, Lead.Country, Lead.City, Lead.Fax, Lead.Email, Lead.OwnerId, Lead.Owner.FirstName, Lead.Owner.LastName, Lead.Owner.Id, Contact.ID, Contact.AccountId, Contact.Salutation, Contact.Title, Contact.Name, Contact.Phone, Contact.MailingStreet, Contact.MailingState, Contact.MailingPostalCode, Contact.MailingCountry, Contact.MailingCity, Contact.Fax, Contact.Email, Contact.OwnerId, Contact.Owner.FirstName, Contact.Owner.LastName, Contact.Owner.Id, Contact.Account.name, Log_A_Call_Notes__c, Contact.Contact_Salutation_Name__c, Title__c, Email__c, Phone__c from Campaignmember where owner_Name__c =: mappingval.get(selectedval) limit 99]; } if (selectedcval != '1' & selectedval != '1' ) { CampaignMember = [select Id, owner_Name__c,Campaign_Name__c , ContactId, LeadId, Status, Lead.Lead_Salutation_Name__c, Country__c, CampaignId, Campaign.Name, Company__c, Lead.Id, Lead.Salutation, Lead.Title, Lead.Name, Lead.Company, Lead.Phone, Lead.Street, Lead.State, Lead.PostalCode, Lead.Country, Lead.City, Lead.Fax, Lead.Email, Lead.OwnerId, Lead.Owner.FirstName, Lead.Owner.LastName, Lead.Owner.Id, Contact.ID, Contact.AccountId, Contact.Salutation, Contact.Title, Contact.Name, Contact.Phone, Contact.MailingStreet, Contact.MailingState, Contact.MailingPostalCode, Contact.MailingCountry, Contact.MailingCity, Contact.Fax, Contact.Email, Contact.OwnerId, Contact.Owner.FirstName, Contact.Owner.LastName, Contact.Owner.Id, Contact.Account.name, Log_A_Call_Notes__c, Contact.Contact_Salutation_Name__c, Title__c, Email__c, Phone__c from Campaignmember where owner_Name__c =: mappingval.get(selectedval) and Campaign_Name__c =: mappingcval.get(selectedcval) limit 99]; } system.debug('SFDC TEST10 *************' + selectedVal); if(selectedsval != '1' && selectedcval != '1' && selectedval != '1') { CampaignMember = [select Id, owner_Name__c, Campaign_Name__c, ContactId, LeadId, Status, Lead.Lead_Salutation_Name__c, Country__c, CampaignId, Campaign.Name,Company__c, Lead.Id, Lead.Salutation, Lead.Title, Lead.Name, Lead.Company, Lead.Phone, Lead.Street, Lead.State, Lead.PostalCode, Lead.Country, Lead.City, Lead.Fax, Lead.Email, Lead.OwnerId, Lead.Owner.FirstName, Lead.Owner.LastName, Lead.Owner.Id, Contact.ID, Contact.AccountId, Contact.Salutation, Contact.Title, Contact.Name, Contact.Phone, Contact.MailingStreet, Contact.MailingState, Contact.MailingPostalCode, Contact.MailingCountry, Contact.MailingCity, Contact.Fax, Contact.Email, Contact.OwnerId, Contact.Owner.FirstName, Contact.Owner.LastName, Contact.Owner.Id, Contact.Account.name, Log_A_Call_Notes__c, Contact.Contact_Salutation_Name__c, Title__c, Email__c, Phone__c from Campaignmember where status =: mappingsval.get(selectedsval) limit 99]; system.debug('SFDC TEST11 *************' + selectedVal); } }catch( Exception e ){ ApexPages.addMessages( e ); } system.debug('##################' + CampaignMember); system.debug('SFDC TEST12 *************' + selectedVal); return null; } List<CampaignMember> results; PageReference pageRef = new PageReference('/apex/AExcel'); public PageReference campaignExport(){ results= [select Id, owner_Name__c,Campaign_Name__c , ContactId, LeadId, Status, Lead.Lead_Salutation_Name__c, Country__c, CampaignId, Campaign.Name, Company__c, Lead.Id, Lead.Salutation, Lead.Title, Lead.Name, Lead.Company, Lead.Phone, Lead.Street, Lead.State, Lead.PostalCode, Lead.Country, Lead.City, Lead.Fax, Lead.Email, Lead.OwnerId, Lead.Owner.FirstName, Lead.Owner.LastName, Lead.Owner.Id, Contact.ID, Contact.AccountId, Contact.Salutation, Contact.Title, Contact.Name, Contact.Phone, Contact.MailingStreet, Contact.MailingState, Contact.MailingPostalCode, Contact.MailingCountry, Contact.MailingCity, Contact.Fax, Contact.Email, Contact.OwnerId, Contact.Owner.FirstName, Contact.Owner.LastName, Contact.Owner.Id, Contact.Account.name, Log_A_Call_Notes__c, Contact.Contact_Salutation_Name__c, Title__c, Email__c, Phone__c from Campaignmember where owner_Name__c =: mappingval.get(selectedval)limit 99]; return pageref; } }
Visualforce Page
<apex:page standardcontroller="CampaignMember" extensions="CampaignListOwner13" showheader="true" sidebar="false"> <apex:sectionHeader title="Campaign Lead Management" /> <apex:form id="calls"> <apex:pageBlock > <apex:outputpanel layout="block"> <apex:outputText >Owner: </apex:outputText> <apex:selectList value="{!selectedval}" size="1"> <apex:selectOptions value="{!selectedOwner}"/> <apex:actionSupport event="onchange" status="counterStatus" action="{!campaignRefresh}" rerender="campPck,calls,calls, status, callList, owners, goToCampaign"/> </apex:selectList> </apex:outputpanel> <apex:outputpanel layout="block" id="campPck"> <apex:outputText >Campaign:</apex:outputText> <apex:selectList value="{!selectedcval}" size="1"> <apex:selectOptions value="{!campaignLists}"/> <apex:actionSupport event="onchange" status="counterStatus" action="{!campaignRefresh}" rerender="campPck,calls,calls, status, callList, owners, goToCampaign"/> </apex:selectList> <br/> <apex:outputText >Status:</apex:outputText> <apex:selectList value="{!selectedsval}" size="1"> <apex:selectOptions value="{!statuslist}"/> <apex:actionSupport event="onchange" status="counterStatus" action="{!campaignRefresh}" rerender="calls, status, callList, owners, goToCampaign"/> </apex:selectList> </apex:outputpanel> <apex:outputPanel layout="block" style="float: right; padding-right: 5px; padding-bottom: 5px"> <apex:commandButton value="Export to Excel" action="{!campaignExport}"/> <apex:commandButton value="Update All" action="{!save}"/> </apex:outputPanel> <apex:outputPanel layout="block"> <apex:outputPanel layout="block" style="clear: both;"> </apex:outputPanel> </apex:outputPanel> <apex:actionStatus id="counterStatus"> <apex:facet name="start"> <apex:outputPanel id="processing"> <apex:pageMessage title="Processing..." severity="info" strength="2" rendered="true" /> <apex:image id="loader" url="{!URLFOR($Resource.CampaignCallDown, '/images/loaderImage.gif')}"/> </apex:outputPanel> </apex:facet> <apex:facet name="stop"> <apex:pageBlockTable value="{!CampaignMember}" var="members" id="calls"> <apex:column value="{!members.Owner_Name__c}" headerValue="Owner" rendered="true" /> <apex:column value="{!members.Campaignid}" headerValue="Campaign" rendered="true" /> <apex:column value="{!members.Country__c}" headerValue="Country" rendered="true" /> <apex:column value="{!members.leadid}" headerValue="Name" rendered="true" /> <apex:column value="{!members.Title__c}" headerValue="Title" rendered="true" /> <apex:column value="{!members.Country__c}" headerValue="Country" rendered="true" /> <apex:column headerValue="Status"> <apex:selectList size="1" value="{!statusupdate}" multiselect="false"> <apex:selectOptions value="{!cStatus}"/> </apex:selectList> </apex:column> <apex:column headerValue="Notes"> <apex:inputTextarea value="{!members.Log_A_Call_Notes__c}" cols="25" rows="1" onFocus="this.rows=3;" onBlur="this.rows=1" /> <br /> </apex:column> <apex:column value="{!members.Email__c}" headerValue="E-mail" rendered="true" /> <apex:column value="{!members.Phone__c}" headerValue="Phone" rendered="true" /> </apex:pageBlockTable> </apex:facet> </apex:actionStatus> </apex:pageBlock> </apex:form> </apex:page>
Thank you for your assistance
For these kind of scenarios its better to always have an wrapper class.
You can have a string property inside the wrapper class and which can different status values of multiple records.
This is similar to a table with checkbox consists of multiple records , and we process only the selected records.