Skip to main content
Tweeted twitter.com/#!/StackSalesforce/status/448368761687769088
edited title
Link
Boris Bachovski
  • 16.3k
  • 8
  • 50
  • 88

Need some help passing Passing a picklist value into a urlURL

Source Link
Ben
  • 11
  • 2

Need some help passing a picklist value into a url

I have created a visualforce page with a dynamic picklist of users of a certain profile. I also have a report setup with a filter that needs a user to be specified.

I want to be able to select a user from the picklist, then click a link that goes to the report and at the same time passes the selected user into the url for the filter.

I think I need to setup an outputLink, but I need some guidance on how the pass the picklist value into the url. Below is the code for my dynamic picklist. Any help would be much appreciated.

<apex:page controller="dynamicpicklist" >
<apex:form >
<apex:sectionHeader title="Manager Portal" subtitle="Special Reports"/>
    <apex:pageblock >
        <apex:pageBlockSection title="Pollinator Inventory Reports" columns="1">
            <apex:outputlabel value="Pollinator" for="values"/>
            <apex:selectList value="{!pollinator}" size="1" id="values">
                <apex:selectOptions value="{!pollinatornames}"/>
            </apex:selectList>
        </apex:pageBlocksection>
    </apex:pageblock>
</apex:form>

</apex:page>

public class dynamicpicklist
{

    public String processLinkClick { get; set; }
    public String pollinator{get; set;}

    public List<SelectOption> getpollinatornames()
        {
          List<SelectOption> options = new List<SelectOption>();
          List<User> pollinatorlist = new List<User>();
          pollinatorlist = [Select Id, Name FROM User ];
          options.add(new SelectOption('--None--','--None--'));
          for (User users : [SELECT Id, Name FROM User WHERE Profile.Name = 'Pollinators' AND IsActive = TRUE ORDER BY Name ASC]) 
              {
                  options.add(new selectOption(users.Id, users.Name));
              }
      return options;
        }
}