• Neil Scott
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hey Everyone,

Very very very new to VisualForce and APEX, but loving it so far!

My first project is tweaking some code I found for VF page that displays Campaign Members. 

I've been trying without success to have the list of Campaign Members displayed ( {!CampaignMembers} ) to be filtered based on the Campaign selected by the user from a list of Campaigns available ( {!campaignList} ).

How can I use this in the SOQL query (getcampaignList) that brings the list of campaign members (WHERE Campaign = Picklist value selected) ?

Thanks in advance!


VF
<apex:page controller="callListController" action="{!getData}" >
    <apex:sectionHeader title="Campaign Call List"></apex:sectionHeader>
    <apex:form >
        
        <apex:pageBlock title="Filters" >
        
            <h2>Select a Campaign:</h2>&nbsp;&nbsp;&nbsp;
            <apex:selectList id="campaignSelected" title="Choose a Campaign" label="Campaign" multiselect="false" size="1">
                <apex:selectOptions value="{!campaignList}"/>
            </apex:selectList>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <h2>Select a Client Relationship Manager:</h2>&nbsp;&nbsp;&nbsp;
            <apex:selectList id="CrmSelected" title="Choose a CRM" label="G1 CRM" multiselect="false" size="1">
                <apex:selectOptions value="{!g1CrmList}"/>
            </apex:selectList>
        
            
        </apex:pageBlock>
        
        <h1 style="color:#FF0000"><apex:actionStatus startText="Saving..." id="status"/></h1>
        <br/>
        
        <apex:pageBlock title="Campaign Members" id="campaignCallList">

          <!-- To show page level messages -->
          <apex:pageMessages ></apex:pageMessages>
          
                  
            <apex:actionFunction action="{!UpdateRecords}" name="updateRecords" rerender="pageBlock" status="status"></apex:actionFunction>
            
            <apex:pageBlockTable value="{!CampaignMembers}" var="cm">

               <apex:column headerValue="Status">
                    <apex:inputField value="{!cm.Status}"  onchange="updateRecords();" />
               </apex:column> 

               <apex:column value="{!cm.Status_Changed__c}"/>

               <apex:column headerValue="Account Name">
                    <apex:outputLink value="https://cs6.salesforce.com/{!cm.Contact.Account.Id}" target="_blank">{!cm.Contact.Account.name}</apex:outputLink>
               </apex:column> 
               
               <apex:column value="{!cm.Contact.Account.Mobile_Clean__c}"/>
               <apex:column value="{!cm.Contact.Account.PersonHomePhone}"/>
               <apex:column value="{!cm.Contact.Account.PersonEmail}"/>
               <apex:column value="{!cm.Contact.Account.PersonMailingStreet}"/>
               <apex:column value="{!cm.Contact.Account.PersonMailingCity}"/>
               <apex:column value="{!cm.Contact.Account.PersonMailingState}"/>
               <apex:column value="{!cm.Contact.Account.Client_Relationship_Manager__c}"/>  
             
               <apex:column headerValue="Campaign">
                    <apex:outputLink value="https://cs6.salesforce.com/{!cm.campaignid}" target="_blank">{!cm.Campaign.name}</apex:outputLink>
               </apex:column>
                                  
            </apex:pageBlockTable>
        </apex:pageBlock>
        
    </apex:form>
    
    <h3>Wishlist</h3>
    <ul>
        <li>Ability to order Campaign Member results by column ASC or DESC</li>
        <li>Status options filtered to only those available on the campaign selected (currently appears to return all options)</li>
        <li>'Status Changed' field re-rendered after 'Status' change, so as workflow update is shown (maybe due to order of execution?)</li>
    </ul>        
        
</apex:page>

CONTROLLER
public class callListController 
{
    private List<CampaignMember> CampaignMembers;

    public List<CampaignMember> getCampaignMembers() 
    {
       return CampaignMembers;
       
    }        
    public void getData()
    {

            CampaignMembers = [SELECT Status, Status_Changed__c, Contact.Account.Phone, Contact.Account.PersonEmail, Contact.Account.Name, Contact.Account.G1_Client_Relationship_Manager__c, Contact.Account.Mobile_Clean__c, Contact.Account.PersonHomePhone, Contact.Account.PersonMailingStreet, Contact.Account.PersonMailingCity, Contact.Account.PersonMailingState, Campaign.name FROM CampaignMember WHERE Campaign.Name = 'TEST' ];    
    }

    public PageReference UpdateRecords()
    {
        update CampaignMembers;
        return null;
    }    

//NEW QUERY FOR CAMPAIGN DETAILS

    public List<SelectOption> getcampaignList() {
        List<SelectOption> options = new List<SelectOption>();
        
        for (Campaign c : [SELECT Id, Name FROM Campaign WHERE Campaign_Call_List__c = true ORDER BY Name ASC]){
            options.add(new SelectOption(c.Id, c.Name));
        }
        
        return options;
    }    

//END OF CAMPAIGN QUERY
//QUERY FOR CRM USER
    
    public list<SelectOption> getCrmList() {
        List<SelectOption> crm = new List<SelectOption>();
        
        crm.add(new SelectOption('','-- None --'));
        crm.add(new SelectOption('Any','-- Any CRM -- '));
        for (Account a : [SELECT Id, Name FROM Account WHERE Is_a_CRM__c = true ORDER BY Name ASC ]){
            crm.add(new SelectOption(a.Id, a.Name));
        }
        
        return crm;
    
    }

//END OF CRM USER
}








Hi I am looking for a easy way to print or export a large Field Dependency matrix in excel. I am new to saleforce please guide me with complete details.
  • January 30, 2014
  • Like
  • 0