Process Builder – How to Pass Variables from a Process to a Flow

This is a follow up question to How do you invoke an external service in a flow triggered by a new Contact Creation?

What I am trying to do is invoke an External Service, passing it some data, when a new Contact is created.

Initially I had issues as described in the link above where I could not invoke my External Service from my Record Triggered Flow due to an "uncommitted work pending" error. The solution to this was to change my Flow to be a AutoLaunched Flow (No Trigger) and to insert a Pause in the flow. Of course I still have to trigger this Flow somehow. I thought of triggering it as a subflow from a Record Triggered Flow but that action does not appear for that particular flow type.

The result of this is that I now have a Process defined in Process Builder that is triggered by Contact creation and its only action is to invoke my Flow. Of course I want the Flow to know the Contact that was created so it can read data and pass to the external service.

I cannot figure out though how to pass any data from my Process in PB to the Flow in FB.

I am also surprised by the hoops I am having to jump through to implement this whole use case. I would have thought this was a common thing to do (Entity Changes in DB => Invoke External Service) that I am wondering if I have just gone about this all wrong.

Best Answer

I have a flow with 2 variables defined. Both variables are configured to be available for input and output outside of the flow:

Variable definition - 1 Apex 1 Text

One of the variables is a Apex-Defined variable from the external service I want to use and the other variable is of type Text.

Only the Text Variable appears in the Process Builder for me to set the value of.

This means that my flow has to assign the fields of the Apex Variable itself, using the data passed in the Text variable.

Variable assignment from Text Variable to Apex Variable

Related Topic