Toggle Side Panel

  • Blogs
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › How can we inactivate users who have not logged in last 120 days?

    Tagged: Admin, Administration Setup, User, User Profile

    • Salesforce® Discussions

      How can we inactivate users who have not logged in last 120 days?

      Posted by Himanshu on April 30, 2016 at 5:45 PM
      Abhinav replied 10 years, 4 months ago 2 Members · 1 Reply
      • Admin
      • Administration Setup
      • User
      • User Profile
    • 1 Reply
    • Abhinav

      Member
      May 27, 2016 at 1:33 PM

      Hi Himanshu,

      List<User> usersToUpdate = new List<User>();
      for(User u : [Select id, IsActive from User where isActive=true and lastLoginDate <= :DATE.TODAY()-120]){
      u.IsActive = false;
      usersToUpdate.add(u);
      }

      if (usersToUpdate.size()>0){
      update usersToUpdate;
      }

      There are some limitation to do this:

      1.Cannot deactivate self user record.

      2.Cannot deactivate a user record which is referenced in another user record in a hierarchy custom field.

      3.Make a Schedule Class apex and invoke via schedule UI in Salesforce. Every night for example.

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    Popular Salesforce Blogs

    Mastering Salesforce Data Migration: A Complete Guide

    Blog in Salesforce Consultant

    Salesforce is a leading CRM platform that helps businesses manage their customer relationships efficiently. However, moving data into Salesforce can be tricky. This guide will…

    CRM Migration, Customer Records, Data Consistency, Data Errors, Data Management
    Nishant Aug 1, 2024
    738  Views
    What are External Data Sources?

    What are External Data Sources? | All You Need to Know

    Blog in Others

    Salesforce is a powerful CRM platform that allows businesses to manage customer relationships, sales, marketing, and customer service in one centralized platform. One of the…

    AWS, Component Events in Salesforce, Cross-platform, Custom Objects, Customer Behavior
    Mohit Kumar Apr 5, 2023
    1,939  Views

    5 Mistakes to Avoid in 2023 When Implementing Salesforce Cloud!

    Blog in Salesforce Implementation

    Salesforce is a potent cloud-based CRM that gives organizations of all sizes capabilities for sales, marketing, and customer service. All of these powerful Salesforce features,…

    Cloud Analogy, common errors, CRM, customised Salesforce Cloud setup, Data Audits
    Hennery cavil Sep 19, 2023
    1,652  Views

    Popular Salesforce Videos

    Manage Record Access and Visibility in Salesforce

    Manage Record Access and Visibility in Salesforce

    Video in Salesforce Training

    Watch this video to learn all about managing record access and visibility in Salesforce. Do let us know in the comment section if you have…

    Salesforce Training, Salesforce Tutorial, Salesforce Records, Salesforce Video, Salesforce Learning
    Pooja Nov 18, 2021
    2,179  Views
    Algoworks attended Dreamfest 2019!

    Algoworks attended Dreamfest 2019!

    Video in Others

    Algoworks attended Dreamfest 2019 and we had the most enjoyable time ever! Fleetwood Mac played at the venue and the crowd went crazy, energy was…

    Salesforce Events, Salesforce Video, DF 19, Dreamforce 19, Dreamfest
    Algoworks Nov 29, 2019
    1,592  Views
    Multipurpose VF Component to Add Multiple Records on a Button's Click | Salesforce Tutorials

    Multipurpose VF Component to Add Multiple Records on a Button's Click | Salesforce Tutorials

    Video in Salesforce Development

    In this video, I will create a multipurpose VF component to add Contact records in a list on the click of a button then I…

    Salesforce Training, Salesforce Developer, Salesforce Tutorials, Salesforce Video, Salesforce Learning
    Kapil Jun 5, 2020
    2,361  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.