0

I am trying to pass a parameter from visualforce on pageload to controller but this is ending up empty. What am I missing?

VFP

<apex:page standardController="Contact" recordSetVar="record" extensions="Ya_ListToStringGeneric" action="{!returnIds}">
    <apex:pageMessages />
    <apex:form >   
        <apex:actionFunction name="flowname" action="{!returnIds}">
            <apex:param name="flowName" assignTo="{!flowName}" value="name" />
             <apex:param name="urlList" assignTo="{!urlList}" value="/003?fcf=00B240000000000" />
        </apex:actionFunction>
    </apex:form>
</apex:page>

Controller

   public class Ya_ListToStringGeneric{
    public string returnstringIDs {get;set;}   
    Public PageReference retURL;
    ApexPages.StandardSetController setCon;
    Public String urlList {get;set;}  
    Public string obj;
    Public String urlVal;
    Public String selectedIds;
    public String flowName {get;set;}
    public String flowName2 {get;set;} 

    public Ya_ListToStringGeneric(ApexPages.StandardSetController controller)
    {
        setCon = controller;
        system.debug(setCon);
        obj = setCon.getRecord().getSObjectType().getDescribe().getName();
    }
    public pageReference returnIds() {
        string flowName2 = Apexpages.currentPage().getparameters().get('flowName'); 
....
        retURL.setRedirect(true);
        return retURL;
    }
}
0

The <apex:actionFunction> command creates a JavaScript function you can call which invokes a controller action. Placing <apex:param> elements there has no effect on the action invoked via your page's action= attribute.

As an aside, use of the action attribute is discouraged because it exposes your application to CRSF attacks.

The only way I'm aware of to do what you want is an approach I wrote up in an answer some time ago: you encode the values of the parameters in the name of the Visualforce page itself. Here, that might get messy (and length-constrained), but at minimum it looks like you could do that successfully with the Key Prefix of the target sObject (or its API name, and then get the key prefix via describe) and the name of the target Flow.

Alternately, name your Visualforce pages with a configuration name, and store the actual configuration in a Custom Metadata record with that same name. Your Apex page can then introspect the configuration name from the page, query the configuration metadata, and obtain its parameters that way.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.