Use Case: Deactivate Users with The Last Login Date

We have utilized the Schedule-Triggered flow to automate sending the emails. Now, we want to show you how to use Schedule-Triggered flow to automatically deactivate the users! In Flow Builder, there is a standard field for the User object called “Last Login Date“. This field makes the solution very easy to build, so let’s dive in!

* Big thanks to Gustavo Seluja for sending in the case!

Lulu Mobile wants to automate their user management. If a user hasn’t logged in for the past 90 days, they want to deactivate this user automatically. At the same time, they want to add a note of “90 Days No Login” in their custom Note field.

(Assumption: There is a “Note” text field on the User object)

We will use the Schedule-Triggered flow. In the automate email post, we created a formula field and let it run daily. However, we cannot do the same for the User object because we can only reference the Last Login Date in Flow Builder but not in the formula field. So instead of evaluating the last login date in Choose Object and Filter Conditions, we will use a Decision element to do so.

This means, whenever the flow runs, all active users will be included in the flow. Thus, I will recommend running this flow weekly instead. Of course if you believe your instance has enough capacity and you don’t have too many users, you can still run this daily.

Flow Chart (deactivate last login date)

Steps (deactivate last login date)

Please wait while flipbook is loading. For more related info, FAQs and issues please refer to DearFlip WordPress Flipbook Plugin Help documentation.

Schedule-Triggered FlowGet RecordsUpdate RecordsAssignment

Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!

Official Salesforce Help Article On Flow

Notify of
Newest Most Voted
Inline Feedbacks
View all comments
Gustavo Seluja

Melody: you nailed it. Beautiful. I tested it today. Thank you!!!!!!

Users inactivated with a flow.jpg

Hi Gustavo,

I’ve just tried to do the same for user who haven’t logged in over 90 days, but it only updated 1 user :/


Hi Melody,

I tried replicating the steps you provided but it didn’t work for me.
I got the following error: Failed to update records whose IDs are in {!$Record}.

I’d appreciate your help.

Here are the screenshots:


Screen Shot 2021-07-27 at 12.19.22 PM.png

Thank you so much for replying.

Although, this time states as completed I still got the same error regarding the login date null.

Skipped this outcome because its conditions weren’t met: Last_Login_90_days_ago.

Screen Shot 2021-07-28 at 1.10.09 AM.png
Al Eric

No chance, I tried different methods and now I got UNABLE_TO_LOCK_ROW error. I checked Google but it seems too advanced for me. How can I resolve that issue? It didn’t work for me.

Al Eric

Hmm, there might be but now I get this error:

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: SendEmailForSalesRepsUserTrigger: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject Trigger.SendEmailForSalesRepsUserTrigger: line 5, column 1. You can look up ExceptionCode value


Hi Melody,

This works like a charm. Thank you for this. Only one thing I would point out is if someone has to do it on thousands of Users (e.g. Customers, Partners Profile Users), it would be better to deactivate the Users which are already beyond the threshold limit of 60/90 days and then schedule this Flow so that there would be less load the first time itself as the number of Users on which the flow has to run would be greatly reduced.