function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chris BraschChris Brasch 

URL Encoding Visual workflow variable to create pageReference

Hi all,

I have created a lead flow where the Finish Location is a pageReference ( for a new lead) contructed from parameters (flow variables) collected throughout the flow. I am experiencing a problem when attempting to constuct the URL where the variables contain spaces, such as "Street". I want to encode the variables gathered from the flow, using the URLEncode Utility class, so that when the URL is constructed in the appropriate format. My code is below...



public class ExistingCustomerLead {

public Flow.Interview.Existing_Customer_Lead_Search myFlow {get; set;}
    public String ExistingCustomer;
    public String getExistingCustomer() {
    if (myFlow==null) return '';
else return myFlow.ExistingCustomer;
    }
    public String City;
    public String getCity() {
        if (myFlow==null) return '';
        else return myFlow.City;
    }
    public String Country;
    public String getCountry() {
        if (myFlow==null) return '';
        else return myFlow.Country;
    }
    public String State;
    public String getState() {
        if (myFlow==null) return '';
        else return myFlow.State;
    }
    public String Street;
    public String getStreet() {
        if (myFlow==null) return '';
        else return myFlow.Street;
    }
  
   
    public String PostalCode;
    public String getPostalCode() {
        if (myFlow==null) return '';
        else return myFlow.PostalCode;
    }

    public PageReference getFinishPage(){

        PageReference p = new PageReference('/00Q/e?CF00N90000001AYrf' + EncodingUtil.urlEncode(getExistingCustomer(), 'UTF-8') + '&RecordType=012900000007FVZ&ent=Lead');
                p.setRedirect(true);
                   
                    return p;
       
    }



}


AUCTUS AdministratorAUCTUS Administrator
Hi Chris Brasch & Community

has anyone got a solution for this? I am experiencing the same problem.

EncodingUtil.urlEncode( SomeString ,'URF-8') 

is not getting me anywhere while trying to build it in a PageReference. 

Any help/suggestion would be very much appreciated. 

Thanks 

Sam