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
BenjaminBBenjaminB 

Reference to flow ID

Hi people,

 

I'm looking for a way to use the ID of the current flow in  a reference.

 

I'm building a flow for people to request contracts. The steps are basically this:

  1. First they choose which company the contract is for (or pass its ID via the url)
  2. They then have to choose which contract
  3. Provide data
  4. confirm and the contract then gets submitted for approval (Thank you so much raja-sfdc for the plug-in for that!)

The problem is that for one contract people need to upload a file to the record. The file upload doesn't work from inside Flow so I've made use of the retURL (which is a parameter in the upload screen url containing the location to return to).

Basically I'm providing a link to the upload page which then returns to the flow afterwards:

 

salesforce.com/p/attach/NoteAttach?pid={!var_RecordID} & parentname={!ret_ContractNumber}
 & retURL=/flow/Contract_Request_Wizard/ {!var_FlowID} ?var_RecordID= {!var_RecordID}

 

This works perfectly except that I have to provide the var_FlowID manually each time. Is there a way that the flow could actually pass its own ID to the var_FlowID?

 

I hope I explained my problem clearly enough and that somebody is able to help!

 

Thanks!

 

Best Answer chosen by Admin (Salesforce Developers) 
BenjaminBBenjaminB

So I fixed it. I have to say I copy/pasted it from someone else, but forgot from where. Thought I'd share it here for others.

 

I created an apex page with the code:

<apex:page Controller="ContractRequestFlowController" TabStyle="Account">
    <br/>
     <flow:interview name="Contract_Request_Wizard" interview="{!myflow}" finishlocation="{!OID}" />
</apex:page>

 And then I also needed a controller:

public class ContractRequestFlowController{
public Flow.Interview.Contract_Request_Wizard myFlow { get; set; }

public String getmyID() {
if (myFlow==null) return '';
else return myFlow.var_RecordID; //Retrieves var_RecordID from the flow. Important is that the var isnt private!
}
   
public PageReference getOID(){
    PageReference p = new PageReference('/' + getmyID());
    p.setRedirect(true);
      return p;}
}

 And this takes the variable "var_recordID" from the flow and uses it as reference. The only thing that I'm puzzled about is that the finish location is {!oid} and that the controller only uses getOID(). Not sure why it works, but it does!

All Answers

RajaramRajaram
Please take a look at https://github.com/raja-sfdc/FlowDynamicRedirect to see how you can pass an ID created within a Flow to be used in the re-direct of the flow after the flow is finished.
BenjaminBBenjaminB

So I fixed it. I have to say I copy/pasted it from someone else, but forgot from where. Thought I'd share it here for others.

 

I created an apex page with the code:

<apex:page Controller="ContractRequestFlowController" TabStyle="Account">
    <br/>
     <flow:interview name="Contract_Request_Wizard" interview="{!myflow}" finishlocation="{!OID}" />
</apex:page>

 And then I also needed a controller:

public class ContractRequestFlowController{
public Flow.Interview.Contract_Request_Wizard myFlow { get; set; }

public String getmyID() {
if (myFlow==null) return '';
else return myFlow.var_RecordID; //Retrieves var_RecordID from the flow. Important is that the var isnt private!
}
   
public PageReference getOID(){
    PageReference p = new PageReference('/' + getmyID());
    p.setRedirect(true);
      return p;}
}

 And this takes the variable "var_recordID" from the flow and uses it as reference. The only thing that I'm puzzled about is that the finish location is {!oid} and that the controller only uses getOID(). Not sure why it works, but it does!

This was selected as the best answer