How to use Custom Settings in Lightning Flows – for frequently changing requirements

I am sure most of you have heard of custom settings within a process builder. Let’s take it a step further – how can we use custom settings in a lightning flow or visual workflow? How can they be used in the use cases with frequently changing business requirements?

Referring to custom settings in Flows

I will first give a bit of background on the two ways you can refer to custom settings in a flow:

  1. Custom settings (Hierarchy type only): these are only available when creating variables of a Formula type.
    This is what I will be using in today’s use case. While creating a variable of formula type, it is under ‘System and Global Variables’ > $Setup as shown below:
  2. 2. Record Lookup / Fast Lookup (as custom objects): if you have multiple records created within a custom setting, you can use this to get values from custom settings and then use Loop element to get the values. A type we can save for next time, but for now, here is a screenshot of what it looks like:

The Use Case: Use frequently changing values from Custom Settings inside a Flow Screen

This is a flow I recently built for a customer, where a District Manager (DM) needs to perform a weekly Assessment at every Location (Account) to remain compliant, by going through a set of questions. An object called Assessments has a lookup relationship to Account. The questions could be changed by the business depending on various factors. For simplicity, I am only using two questions here. These appear as picklists fields on the Assessment object, with Yes/No answer options – these are Q1 Floor Cleaning and Q2 Stock.

The DM should be able to click a button from his/her Location(Account) page and launch the questions. To make this happen, we will use a Screen type flow process and call this flow from a Lightning Action.

You might be thinking what do I need custom settings for?

As I mentioned, the questions are susceptible to change:

  • First of all, the fields ‘Q1 floor cleaning’ and ‘Q2 Stocks’ don’t say much about what the DM needs to be checking on. They don’t have verbiage (context). We need a way to incorporate verbiage within the flow to tell the DM what he/she needs to do.
  • Secondly, as we know field names have character limits, we can’t have a field with a long name and add the verbiage there.
  • Finally, what if the business decides to change the questions? Trust me, it happens often! If it does happen, you will not need to edit your flow – all you will need to do is update the values inside the custom settings.

First, create two Custom Setting of type Hierarchy and public for the two questions.

If you have not created custom settings before, follow these steps:

  1. Go to Set up > Type custom settings > Click New
  2. Label = Q1 Actions, Name = Q1_Actions, Setting Type = ‘Hierarchy’, Visibility = ‘Public’, Include a description as needed.
  3. Click Save.
  4. On the next page, Click New under custom fields. Select the field type as Text Area. Then Name it as Q1 checklist.
  5. Now, click Manage and Click New under the Default Organization Value.
  6. Type in the question verbiage given by the business for Q1.
  7. Follow the same steps to create another custom settings called Q2 Actions and create a field Q2 Checklist. Then enter a verbiage for Q2.

Now it’s time to create the flow which refers to these custom settings so that the user knows what compliance checks to make in order to answer each question.

Here is what the flow looks like:

First element:

Create a variable of Text type and call it ‘recordId’. The input/output type of this variable should be set to Input only. The recordId can be passed from the Account page.

After the recordId is passed from the page to the flow, the lookup element looks for the name of the Account and then assigns the name to an sObject variable of Account type {!varAccount.Name}.

Make sure when you create the sObject variable, the Input/Output type is set to Input/Output type.

Second element:

Create a screen type element where the user will see the Q1 checklist values and Q2 checklist values from the custom settings. To get the values from the custom settings into the flow, we will use a formula variable, as mentioned at the beginning of this post.

On the left hand side of your flow, click on the Resources, then double click on formula. Give it a name Q1Checklist, description as needed and then under Resources, you will see the custom settings Q1_Actions__c.Q1_checklist__c as in the screenshot below:

Repeat the same process to create a formula called Q2Checklist and get the custom settings from Q2_Actions__c.Q2_Checklist__c.

{!Q1Checklist} and {!Q2Checklist} on the screen element are these formula variables.

‘Who is the GM associated with this Location’ is just a text input field to get the email of the General Manager. Q1 Floor Cleaning and Q2 Stocks are two drop-down type of input screen variables.

In the next element, we will assign these screen output fields to the Assessment fields to create Assessment record.

Third element:

A Record Create element assigns various fields from the flow to the Assessment fields and creates an Assessment record. {!Q1}, {!Q2_Stocks},  {!Who_is_the_GM_associated_with_this_location} are screen output fields.

Last Step:

Create a Quick Action on the Account object and call this flow from the Quick Action. Here is what it looks like when the flow is called from an Action on an Account page:

As you can see, if your business wants to change the questions, all you will need to do is change the values within the custom settings. This is what led me to explore this use case. I didn’t want to make more changes to my flow, and have to save as a new version every time.

Summary

Congratulations! You just utilized the power of flow with custom settings and Quick Actions to make your flow even more dynamic. This is just one of the use cases I have used so far, and I am hoping to explore it further!

Feel free to modify this and make your own flow for any of the business problems you are trying to solve. Play around and explore to see where you can use flows in general and custom settings. Please share your use cases, I would love to hear them!

Subscribe To The Monthly Newsletter

No Spam. No Rubbish. Just great content from the Salesforce Industry.

You have Successfully Subscribed!

Add Comment