Finding Lost Variables

I have spent the last few weeks buried by a crazy flow. This flow does everything but make you lunch sadly. Would have been really helpful if it did when I was on my 15th time through it in debug mode trying to figure out why it wasn’t behaving as expected.

For days I struggled with my variables being reset if the user clicked the previous button. Per Salesforce this is the expected functionality and there is no way to turn it off or create a work around.  Or so I could find…

By setting inputs and outputs I could make it look to the user like the data was being maintained since we were using Lightning Components on our flow screens. But that did not stop the flow from creating a new case every single time.

I tried assigning the variables, looking them up, everything I could think of, but no matter what I did, if the user clicked previous after the case creation action, a new case would be created when they moved forward, except now I couldn’t look up the case because I didn’t have the case ID anymore. My variable was set to null every blasted time. I was stumped.

Then in a moment of clarity, I realized I could leverage the unique identifier for that particular run of the flow to identify the case that had just been created. And, guess what? It worked. No more duplicate cases. They were being properly updated when the user clicked previous and made a change.So here is how I did it.

Before I started this, I created a field on the case for storing the Flow Interview Guide ID.

1. The first step of the flow is a screen where the user inputs the information that would be used to create a case. This information is stored in an sObject variable.

2. Then to get this to work, the next step is to lookup a case with the Flow Interview Guide that matches the current interview and assign the record ID to the ID field for the sObject variable. Make sure you check assign null value if a record is not found.

3. Now its time to leverage a decision step. If the ID is left blank by step 2, then move onto creating the case. If the ID has a value, then its time to update the case.

4. For path where you create the case, make sure you populate the field on the case for the Flow Interview Guide. This is important or all your hard work on setting up the look up and decision with be for naught.

You can repeat this numerous times throughout the flow as you create additional records. A few extra steps in my flow gave me the flexibility to let my users click the previous button and update any mistakes.

 

Comments

  1. V.A. says:

    Thank you for this. I had the same exact scenario with getting duplicate records and your solution worked wonderfully! Big kudos for writing this up.

Leave a Reply

Your email address will not be published. Required fields are marked *