How to use Login Flow in Salesforce

Salesforce login procedure was like all other web applications around us where we need to provide username and password. Few years back, Salesforce also introduced two step authentication process by using mobile SMS feature. Salesforce also supports SSO, where we can have custom identity provider and custom authentication can be implemented like RSA token based, Yubikey etc. Previously there were no way to participate in standard login process of Salesforce however from Winter 15, we have one more feature known as login flow.

Using Login flow, we can participate and change login process of Salesforce. To explain more, lets consider below problem definition which we will try to solve using login flow in this post.

Problem definition :

Customer has implemented IDp initiated SSO. Whenever any user is logging into corporate network, start up script automcatically uses IDp initiated login to auto start Salesforce. Management wants to know that how many users are really using system and deacticate all users who has not used it in last 45 days.

How to solve ?

As all users are automatically getting logged into system because of startup script , we cannot use standard report to get users who has not logged into salesforce in last 45 days. In this situation we can create custom solution using Login flow.

Solution is very easy. We will create custom object and insert login detail into this object if user accepts terms and condition everytime when trying to login into system. If startup script opens Salesforce page and user ignores selecting terms and condition then it will not create any record.

What is Login flow ?

Login flow is not very new concept to Salesforce admins or developers. It is nothing but flow which can be set into Login flow for each profile.

Security in Login flow

If user is in login flow screen and try to bypass it by directly navigating to URL then Salesforce throws insufficient privileges error because user has access to only login flow, nothing else.

Detailed steps :

Create Custom Object by name something like “Login Detail” with Name as autonumber type and custom field of type lookup to user as shown in below image.

Salesforce Login Flow - Custom Object
Salesforce Login Flow – Custom Object

Create new flow by navigating to “Setup | App Setup | Workflow and Approvals | Flows | New Flow“.

Drag Screen component from left to canvas panel and name it something like “Welcome”.

Salesforce Login Flow - New Screen Component
Salesforce Login Flow – New Screen Component

Then add two fields on screen by clicking on “Add a Field” tab, In this case I have added below fields

  • Display Text
    • Unique Name – Line1
    • Text – Welcome to Login Flow Demo
  • Checkbox
    • Label – Do you want to continue
    • Unique Name –  Do_you_want_to_continue

We will use above checkbox in next component to decide that user has selected to go ahead or not ?

Salesforce Login Flow - Checkbox component
Salesforce Login Flow – Checkbox component

Now its time to add new component in flow. Drag Decision component from left to canvas and enter values like below screen

Salesforce Login Flow - Decision component
Salesforce Login Flow – Decision component

As shown in above image, we need to create outcome by name “Yes” and in condition we are checking that screen input field “Do_you_want_to_continue” is equal to true or not. Default outcome we are considering as No.

Now create a formula field by navigating to “Resources” tab and double click on “Formula”. This formula will hold current logged in user as shown in below image.

Salesforce Login Flow - Formula Field
Salesforce Login Flow – Formula Field

Its time to add final element in flow. Drag “Record Created” component on canvas and enter values as shown in below image

Salesforce Visual Flow - Record create component
Salesforce Visual Flow – Record create component

In above image, we are creating record in custom object created in first step with value in user field from Formula we have created.

Now connect “Yes” decision to recorc create component and No to Welcome screen by dragging mouse from descision to destination component as shown in image. Also, dont forget to mark Welcome screen as “start element”. It can be done by selecting green arrow at upper right corner of component.

Salesforce Login Flow
Salesforce Login Flow

Activate above flow and navigate to “Setup | Administration Setup | Security Controls | Login Flows | New”. Select recently created login flow and profile for which it should be enabled.

Salesforce Login Flow Connection
Salesforce Login Flow Connection

We are all set now, logout and try to login again. You will be prompted with message if your profile matched with login flow and record will be created in custom object.

This is just one demo of small problem, possibilities with login flow are endless. It is suggested as a best practice not to use Login flow for System administrators, If some issue arises they should be in position to rectify and correct it.

More resources

Video tutorial of this blog post can be found on my live streaming channel. Start watching it from 15th minute, there is no sound in initial video.

If you want to learn more about visualflow then visit cool blog of my buddy Rakesh, which has many cool tutorials mainly focused on visualflow.

Read more on Login flow on official blog post and install existing login flow examples provided by Salesforce from here.

Posted

in

by


Related Posts

Comments

10 responses to “How to use Login Flow in Salesforce”

  1. Rakesh Gupta Avatar

    Awesome-sauce! Love this.
    Thanks for the mention and for linking to my blog!

    1. Jitendra Zaa Avatar

      Your blog is of worth to mention if its about Visualflow 🙂

      1. Rakesh Gupta Avatar

        Thank you 🙂

  2. Muneesh Bhalla Avatar
    Muneesh Bhalla

    Here is caution. Do not use this for Administrator’s profile, If some bug is there in the flow then Administrator will not be able to log in. Awesome posts on Porces Builder and Flows by Rakesh Gupta.

  3. sravani Avatar
    sravani

    I implemented login flow in my developer org for system admin profile.
    For de-activating login flow i didn’t find any option so i deactivated the flow which is assigned to that login flow. Now unable to login to my account, getting screen which contains this message
    ‘Flow “Test” is not found or doesn’t have an active version. Please contact your administrator for more information.’

    please help me

    1. Jitendra Zaa Avatar

      I can think of two solution here –
      1. Contact Salesforce support to fix this
      2. Use eclipse or workbench to deactivate login flow using metadata deployment

      1. Inglorious Afficianado Avatar
        Inglorious Afficianado

        Hi Jitendra,

        I cant even Log Into workbench or eclipse using the same credentials. I ave my username and password. But i get the same issue anywhere i login with these credentials

  4. Subba Salesforce Avatar
    Subba Salesforce

    Hi @JitendraZaa:disqus
    The login flow is not working with IE11,Can you please suggest me how to resolve the issue?

    Thank You

  5. […] How to use Login Flow in Salesforce – Jitendra Zaa’s Blog […]

  6. Pavan Avatar
    Pavan

    can we use login flow to check userip and restrict logging in ?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading