Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • 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
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • 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
    • Marketplace
    • Advertise With Us
    • 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 9 years, 8 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

    application solution

    Popular Salesforce Blogs

    Top 7 Salesforce Commerce Cloud Features Every eCommerce Brand Should Use in 2025

    Blog in Salesforce Cloud Platform

    eCommerce is no longer just about having an online store. It's about creating experiences that make customers want to come back. And in 2025, that…

    Salesforce Commerce Cloud
    Amit Nov 12, 2025
    507  Views
    Salesforce consulting companies help your business grow

    How do Salesforce consulting companies help your business grow?

    Blog in Salesforce Consultant

    Salesforce has time and again proven to be the best platform-as-a-service cloud CRM in the world. At present, Salesforce is the most widely used cloud…

    Customer Experience, Salesforce Applications, Salesforce Apps, Salesforce Consultant, Salesforce Consultants
    Algoworks Aug 13, 2019
    6,361  Views
    salesforce appexchange

    What is Salesforce AppExchange - Everything You Need to Know

    Blog in AppExchange

    Working with Salesforce is like tackling new challenges and customizing your org for your requirements. Salesforce has plenty of standard functionalities that can manage the…

    AppExchange, Apps, Apps in the AppExchange, Big Businesses, Builds the App
    Anjali Aug 10, 2020
    3,148  Views

    Popular Salesforce Videos

    Salesforce Admin 201 Training for Beginners: Different Types of Relationship in Salesforce

    Salesforce Admin 201 Training for Beginners: Different Types of Relationship in Salesforce

    Video in Salesforce Training, Salesforce Admin

    The Salesforce Certified Administrator program is designed for individuals who have experience as a Salesforce administrator. The program encompasses the breadth of applications, the features…

    Salesforce Training, Salesforce Certification, Salesforce Administrator, Salesforce Admin, Salesforce Video
    Pooja Jul 9, 2020
    1,468  Views
    Approval Process In Salesforce | Salesforce Development Tutorial

    Approval Process In Salesforce | Salesforce Development Tutorial

    Video in Salesforce Training

    Approval process in Salesforce. This video will cover the following points - 1. Approval Process Learn how to create an approval process. 2. Manage Approval…

    Salesforce Training, Salesforce Tutorial, Salesforce Development Tutorial, Salesforce Video, Salesforce Learning
    Algoworks May 24, 2021
    1,854  Views
    Welcome to the New World of Data Collection | Salesforce

    Welcome to the New World of Data Collection | Salesforce

    Video in Others

    Secure data collection built for your needs. With FormAssembly, your organization can streamline outdated processes and power important business initiatives. Click the link below to…

    Salesforce Training, Salesforce Tutorial, Salesforce Administration, Salesforce Developer, Salesforce Integration
    S2 Apr 1, 2022
    2,074  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®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.