I'm trying to create a public facing visualforce page that doesn't require login. Users will be able to select a campaign of a specific record type, and then select an opportunity where the Primary Campaign Source is equal to the selected campaign in the first picklist. Ideally, the picklist options will only be opps related to the selected campaign, but I currently have it showing all opps of a specific record type.
Once the user selects both Campaign and Opportunity, I'd like to display a list view of Opportunity Contact Roles with some custom fields. The Opp Contact Roles that display should only be contacts related to the selected Opportunity.
I'm not familiar enough with VF to know what's needed to filter results of the Opportunity picklist and then create a list view of Opp Contact Roles based on the selected opportunity. Could someone please review my code to make sure I'm on the right track and provide advice for how to accomplish my end goal?
Thank you!
Here is my code for the VF page:
<apex:page controller="eventSelector">
<apex:pageBlock title="Event Selector">
<apex:form >
<apex:pageBlockSection title="Meets/Road Races">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Campaign" />
<apex:selectList value="{!selectedCampaign}" size="1">
<apex:selectOptions value="{!campaignOption}" />
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:form>
<apex:form >
<apex:pageBlockSection title="Events">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Opportunity" />
<apex:selectList value="{!selectedOpportunity}" size="1">
<apex:selectOptions value="{!opportunityOption}" />
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:form>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection title="Event Status">
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Here is my code for the controller:
public class eventSelector {
public List<SelectOption> campaignOption{set;}
public List<Campaign> campList{get;set;}
public String selectedCampaign{get;set;}
public List<SelectOption> getCampaignOption() {
List<SelectOption> options = new List<SelectOption>();
campList = [Select Id, Name From Campaign Where RecordTypeId = '0125Y000001urOCQAY'];
for(Campaign camp : campList) {
options.add(new SelectOption(camp.Id,camp.Name));
}
return options;
}
public List<SelectOption> opportunityOption{set;}
public List<Opportunity> oppList{get;set;}
public String selectedOpportunity{get;set;}
public List<SelectOption> getOpportunityOption() {
List<SelectOption> options = new List<SelectOption>();
oppList = [Select Id, Name From Opportunity Where RecordTypeId = '0125Y000001yoScQAI'];
for(Opportunity opp : oppList) {
options.add(new SelectOption(opp.Id,opp.Name));
}
return options;
}
}