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>
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;
}
}
Attribution to: Ben
Possible Suggestion/Solution #1
<apex:outputLink value="/apex/destination?picker={!pollinator}">link</apex:outputLink>
The controller side for the same
String pickerstr=Apexpages.currentpage().getParameters().get('picker');
//code to parse into list again
public static List<String> stringparse(String str){
str=str.remove('(');
str=str.remove(')');
str=str.deleteWhitespace();
List<String> lst=str.split(',');
return lst;
}
List<String> pickers=stringparse(pickerstr);
Then you can use this list in query with 'IN' clause .
Attribution to: Mohith Shrivastava
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/30843