I'm trying to pass a value selected from a SOQL query, from the VF page to a Visual Workflow. The value I am trying to pass is selectedRibbonClauses. I dont get an error message when i try to save the VF page or controller, but the value doesnt show up in the flow when i try to reference it. When I hardcode a value for the selectedRibbonClauses field, it gets passed into the flow and shows up in the screen element. Can someone help me, where I'm going wrong?
Part of me thinks it could be something as simple as my syntax or how I'm referencing the variable in the code.
<apex:page controller="RibbonClauseSearchControllerv2">
<apex:form >
<apex:pageBlock rendered="false" >
<apex:pageBlockButtons >
<apex:commandButton action="{!back}" value="Back"/>
</apex:pageBlockButtons>
<apex:pageMessages />
<apex:pageBlockSection title="You Selected" columns="1" collapsible="true">
<apex:pageBlockTable value="{!selectedRibbonClauses}" var="rc2" style="width:100%">
<apex:column value="{!rc2.rc.Name}" headerValue="Name" Style="width:100px"/>
<apex:column value="{!rc2.rc.Text__c}" headerValue="Language" Style="width:600px"/>
<apex:column value="{!rc2.rc.Id}" headerValue="Id" Style="width:1px" rendered="false" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<flow:interview name="Approval_Record_Creation" buttonLocation="top" finishLocation="/{!$CurrentPage.parameters.Id}">
<apex:param name="vRibbonClauseId" value="{!selectedRibbonClauses}" />
<apex:param name="v_UserId" value="{!$User.Id}"/>
<apex:param name="vMId" value="{!$CurrentPage.parameters.Id}"/>
</flow:interview>
</apex:page>
Below is my controller:
public class RibbonClauseSearchControllerv2 {
// the results from the search. do not init the results or a blank rows show up initially on page load
public List<RibbonClauseWrapper> searchResults {get;set;}
// the categories that were checked/selected.
public List<RibbonClauseWrapper> selectedRibbonClauses {
get {
if (selectedRibbonClauses == null) selectedRibbonClauses = new List<RibbonClauseWrapper>();
return selectedRibbonClauses;
}
set;
}
// the text in the search box
public string searchText {
get {
if (searchText == null) searchText = 'Type Value'; // prefill the search box for ease of use
return searchText;
}
set;
}
// constructor
public RibbonClauseSearchControllerv2() {}
// fired when the search button is clicked
public PageReference search() {
if (searchResults == null) {
searchResults = new List<RibbonClauseWrapper>(); // init the list if it is null
} else {
searchResults.clear(); // clear out the current results if they exist
}
// Note: you could have achieved the same results as above by just using:
// searchResults = new List<RibbonClauseWrapper>();
// dynamic soql for fun
String qry = 'Select rc.Name, rc.Id, rc.Text__c, rc.Clause_Name__c, rc.Additional_NST_Details__c From RibbonClause__c rc Where rc.Name LIKE \'%'+searchtext+'%\' Order By rc.Name';
// may need to modify for governor limits??
for(RibbonClause__c rc : Database.query(qry)) {
// create a new wrapper by passing it the category in the constructor
RibbonClauseWrapper rcw = new RibbonClauseWrapper(rc);
// add the wrapper to the results
searchResults.add(rcw);
}
return null;
}
public PageReference next() {
// clear out the currently selected categories
selectedRibbonClauses.clear();
// add the selected categories to a new List
for (RibbonClauseWrapper rcw : searchResults) {
if (rcw.checked)
selectedRibbonClauses.add(new RibbonClauseWrapper(rcw.rc));
}
// ensure they selected at least one ribbonclause or show an error message.
if (selectedRibbonClauses.size() > 0) {
return Page.RibbonClause_Results;
} else {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one RibbonClause.'));
return null;
}
}
// fired when the back button is clicked
public PageReference back() {
return Page.RibbonClause_Search;
}
// fired when no clause available button is clicked
public PageReference noclause() {
return Page.clauseKeyPage;
}
}
Here is my wrapper:
public class ribbonClauseWrapper {
public Boolean checked{get;set;}
public RibbonClause__c rc{get;set;}
public RibbonClauseWrapper(){
rc = new RibbonClause__c();
checked = false;
}
public RibbonClauseWrapper(RibbonClause__c rc2){
rc = rc2;
checked = false;
}
}