1

Guys I have a requirement to execute a piece of code only once. I created a flow to call a invokable method and called this flow from login flow. This was working fine and the code is being called only once. The issue here is when a newly registered user tries to login into the application, instead of redirecting to the user to the default page(visualforce tab based on user profile) an intermediate page("Your Flow Finished" page of the flow) is being displayed. This happens only during the first time login or if there is any change in the flow. Is there any way to stop or avoid this behavior? Is there any other approach to invoke a class only once.

2 Answers 2

0

Use of static variables might be an option to do this. Declare a static variable in a class and set it to false on declaration. Every time you enter the flow check the value of this variable before, enter the flow only if this value is false.

Once your flow begins set this variable to true. So that when the code tries to invoke the class for a second time it detects that the code has already run once and prevents running again. Hope this helps. Thanks

2
  • Stygon, thanks for the quick reply. Using the flow I am able to achieve the one time execution requirement. But the problem with this approach is during the first time login im getting a flow finished page which is not reproducible when i login next time. I want to suppress this page if im going to use the flows. Else I need any other approach to execute code during login.
    – Sachin SB
    Commented Jan 6, 2016 at 15:45
  • Just a suggestion, when a user finishes the flow successfully for the first time - you could set a boolean field in the user record true. Based on this field value now you can decide to redirect the user to the home page.
    – Prajith
    Commented Jan 6, 2016 at 15:52
0

You're looking to set the LoginFlow_FinishLocation variable...

LoginFlow_FinishLocation - String type. Setting this variable will determine where to send the user when the flow completes. [https://developer.salesforce.com/page/Login-Flows]

You need to set it with an Assignment element to make it go - but yeah, thats the way to do it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .