Setting flow finish behavior without a custom controller

Until now, in order to redirect the user to a record created in a flow, you needed to embed the flow in a visualforce page, and use a custom apex controller to get the record Id from the flow so you can use pass it to a pagereference method and direct the user to the record.

This meant that you could not use lightning runtime (as flows embedded on visualforce pages will only use classic runtime) and that you needed to write up a custom controller.

No longer! With winter18, you can use the lightning flow component on a visualforce page - and that component automatically has access to flow variables via the outputVariables variable/property. (i have very limited js knowledge so please share the correct terminology).

Start with the sample code on developerforce.

It has a couple of issues and will not work as written, but a fine fellow who goes by Charles T on sfse guided me to a working proof-of-concept.

The two issues w the code as wrriten are

  1. the statusChange function will never be called.
  2. the provided structure of the for…in loop will pull the keys, not the values,

the ways to address this are documented in the answer

  1. add this property/parameter when you instantiate the flow component with lightning.createComponent : {"onstatuschange":statusChange}

  2. pull in the variable value using the key
    for (key in outputVariables){
    if outputVariables[key].name == 'vaOutput' {
    // make your decisions here
    }

    }

and you can watch a sample here : https://video.twimg.com/tweet_video/DQIQJvjW0AAP-UI.mp4

 
8
Kudos
 
8
Kudos

Now read this

Working with Existing Attachments in Visual Workflow

You can manipulate attachments in visual workflow (i’m working with the old-fashioned attachments object, but this should work w/ files, which are stored as contentDocument / contentVersion / contentDocumentLink). What works:... Continue →