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, 3 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

    Salesforce Predictions for 2025: A Glimpse into the Future of CRM

    Blog in Salesforce

    As we embark on a new year, it's exciting to anticipate the innovations and trends that will shape the future of CRM. Salesforce, the industry…

    Attributes in Salesforce, Prediction, Salesforce CRM
    Cloudy Aug 1, 2025
    303  Views
    Salesforce Security using CRUD, FLS, and sharing rules

    Salesforce Security using CRUD , FLS & Sharing Rules | Salesforce Guide

    Blog in Salesforce

    Salesforce is a cloud-based Customer Relationship Management (CRM) platform that allows businesses to manage their sales, marketing, and customer service activities in a more efficient…

    Create, Custom Picklist Field, Delete, Field Level Security, Field Values
    Mohit Kumar Mar 21, 2023
    2,783  Views

    The Intelligent Commerce Stack: How Salesforce is Powering the Next Generation of Online Retail

    Blog in Salesforce

    Online retail faces growing challenges: managing complex operations, integrating multiple sales channels, and delivering personalized, consistent experiences across B2C and B2B segments. Traditional commerce systems…

    Susan Nov 11, 2025
    383  Views

    Popular Salesforce Videos

    Introduction to Salesforce and Data Modeling | Quick Start | Episode 1

    Introduction to Salesforce and Data Modeling | Quick Start | Episode 1

    Video in Data, Salesforce Training

    In this video, you will get started with Salesforce Development and build Salesforce Applications without writing code. Watch this video and learn. 00:00:00 - Start…

    Salesforce Tutorial, Salesforce Development, salesforce, Salesforce Apps, Cloud Computing
    Prafull Jul 13, 2021
    2,069  Views
    Dynamic Report Charts & Customer 360 View in Salesforce - Learn Salesforce Series By Algoworks

    Dynamic Report Charts & Customer 360 View in Salesforce - Learn Salesforce Series By Algoworks

    Video in Others, Salesforce Training

    In this video, the following points will be covered - 1. Introduction Introduction to conventional setup for Customer 360. 2. Prerequisites Setting up a base…

    Salesforce Development, Salesforce Reports, salesforce, salesforce services, Salesforce Cloud
    Algoworks Sep 18, 2020
    1,710  Views
    Exploring Technology Choices For Salesforce Integration

    Exploring Technology Choices For Salesforce Integration

    Video in Others

    Are you struggling to find the perfect technology to integrate Salesforce into your business processes? Integrating Salesforce into your business processes can offer significant advantages,…

    salesforce, Salesforce Video, Salesforce VIdeos, salesforceintegration, salesforcepartner
    Cyntexa Oct 23, 2023
    992  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.