It’s not often I get excited thinking about the possibilities for something, but as of Summer ’15 I don’t see a reason why every Salesforce org shouldn’t have at least one Login Flow queued up and ready to be used at the switch of a custom setting
Login Flow is one of those underrated pieces of Salesforce that people just haven’t started using yet. I think that entering the world of Flow can be scary for a lot of people, and at first glance it also appears relatively inflexible. You can set a message, but you have to set the same message for everyone in a profile, you assign it by profile, and to change the message you have to create a new version of the flow. Just saying the words “New Version” is enough to scare off clients with a structured deployment and ALM process
This question came up on the Success Community today which triggered my memory on the release notes, which got me thinking how we can really make this work and be flexible for both messaging, and also the timing of when the message is used.
Login Flow in its most basic form is:
- A screen element in a flow with some text
- A login flow assigning the screen to each applicable profile
- Someone logging in and seeing it
The problem is that the entire profile sees the same message, and to stop the message you have to delete the login flow, or deactivate the flow itself.
What we want to do is extend that basic functionality so that the messaging can be easily turned on and off, and also customized. Something as simple as addressing the user by name can really show the extra effort that has been put into your solution.
If you’ve come this far and are still scared of trying flow, head to Rakesh’s site. I’m starting to feel like a broken record on this one.
I liked using my Dev Org for this because
- I can try it out and make sure it makes sense
- I was quickly able to answer someone who asked if it showed up on Salesforce1
- I can tell myself funny jokes
So let’s get to it
Configurable Login Flow
It’s great when you have someone like Deepak around to track down the area of the release notes for you where it talks about Flow now accessing Global Variables, which is really what makes this possible.
So instead of hardcoding everything, we are going to create a custom label to hold the message, and a custom setting to determine whether to even show it at all.
Once you’ve finished with this, and my next post extending this solution, you’ll be able to think of all sorts of use cases now that Summer ’15 has arrived.
Custom labels are great as a way to store text in a place that still makes it configurable later on. The obvious example is storing messages outside of Apex so that you don’t need to change the code to change the text – but it works for items like Flow as well. In this case I can store the message outside of the flow, so that if I ever want to make a change I don’t need to create a new version. I can also pass off the message handling to another person in the organization. This facilitates a much more agile process for changing the messaging
Setup > Create > Custom Labels > New
Here’s another area that isn’t used nearly enough in most orgs. Custom Settings provide a ton of flexibility (like here!) once you get going with them. If you want a good explanation of where they are useful try this one
First I need to create the setting from Setup > Develop > Custom Settings and make sure the type is Hierarchy
Second I need to create a new checkbox field as part of the setting
Third I need to set the Org Wide Setting to True for the checkbox. We will reference this in our flow.
(I could also control it by Profile, or even by User)
Don’t be scared of the custom setting. Just recently I was barely able to convince a client to use the Login Flow functionality, specifically because it couldn’t easily be turned on and off. This solves that problem – as you’ll see
At this point we have everything we need outside of the flow, so now it’s time to build the thing.
- We have a custom label that provides our message
- We have a custom setting to determine whether it should run or not
Building our Flow
Our flow is going to consist of:
- Formulas to access the Custom Setting and Custom Label
- A Decision Element to check the setting
- A Screen to display the best
First open the cloud flow designer – Setup > Create Workflow & Approvals > Flows – and click on New Flow
Create a formula from the Resources tab fRunFlow to pull in the custom setting
Create another formula called fMessage to pull in the custom label
Have you stopped because you are getting confused? Seriously, check out Rakesh’s blog and do a few exercises. You’ll be fine. This is why you use a Dev Org for this stuff, screw it up and your computer is the only one that will know, silently mocking you for ignoring instructions, just like the time you thought using Internet Explorer again was a good idea. Don’t worry, this one is almost impossible to screw up.
So now we have our two formulas to access our Custom Label and Custom Setting sitting in our Flow. Time to move to the Palette and get this thing going.
Personally, I like to drag in the Screen first. Personal preference, but it’s where I like to start. So drag in a screen element and call it something like Welcome Screen. Navigate to the Add a Field tab and drag in a Display Text Output. Name the Output, and then select your fMessage as the resource.
Next you need to determine whether the flow should run or not, which is where your Custom Setting comes in. Drag a Decision element onto the page, and create two outcomes based on the Custom Setting:
Last step is to make the Decision your starting element, and connect the Decision to the Screen if Run Flow is the decision
That is your entire flow. If you’ve made it this far you are probably sitting back thinking huh, that wasn’t so bad
Minor (major!) Details:
- Save your flow with a name
- Close the Flow Designer
- Click Activate beside the flow version
Setting up the Login Flow
This is the easy part, I mean really easy. My only recommendation, unless you are feeling daring, is to set it for a different profile and use one of the other profiles that come with your dev org and a dummy user to test it the first time. Nothing says success like hitting an error in the flow and locking yourself out of your own org. Again, at least with a Dev Org nobody needs to know
Setup > Security Controls > Login Flows > New button
Running your Flow
If I have to explain how to run a Login Flow then we’ve got problems. One thing worth highlighting is that the Admin login as any user won’t trigger this. It needs to be a real login, which is why I recommend a dummy user for testing. If you are going to use yourself, at least also have Salesforce open already in another browser just in case something goes wrong.
Assuming you followed the directions, you’ll be seeing a screen welcoming you and giving you a little encouragement.
Now go back and uncheck the custom setting and try again, you’ll notice that the screen doesn’t appear
Now change the message, you’ll see the changes without having to create a new version of the flow
Having access to Custom Settings and Custom Labels, along with other global variables is a pretty big deal. The sky is the limit with how you can customize the Login Flow every since Summer ’15
In my next post I want to extend this further to show you how to expand on customizing the login flow for each user, based on different settings, and really getting into different ways of thinking about how this could be useful for your own organization.
This one almost as is would be perfect to turn on and off, and adjust the wording, during deployments and any situation where you don’t want to lock users out, but do want to warn them of something, or just wish them happy holidays for a week. Either way – you now have that option