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

    Salesforce Developer

    Advantages of a Salesforce Developer for Startups and Small Businesses

    Blog in Salesforce Consultant

    If you are considering starting a startup or have already set up a small-scale business. This Salesforce article will help boost your business growth. Salesforce…

    AppExchange, Apps, Business Growth, Business-customer Relationships, Client Data
    connect@codinix.com Aug 24, 2022
    3,054  Views
    Salesforce Professional Edition

    How I Failed to Upsell to a Customer Because I Recommended Salesforce Professional Edition

    Blog in Sales, Salesforce

    I am sharing this story because of how important it is for consultants like myself to not make hasty decisions when making recommendations on Salesforce…

    Budget Limitation, Business, Business Process, Commercial, Commercial Proposal
    Blondie Dec 8, 2021
    4,547  Views

    Salesforce User Stories: Salesforce Adoption Experience of FinTech Leaders Globally

    Blog in Salesforce Stories

    The fintech market is substantially evolving and has an expected value of $698.48 billion by 2030, a considerable contrast to its $110.57 billion valuation in…

    Application Submissions, Automated Client Account Openings, Automated Workflows, Automation, Banking
    Sparkybit Dec 11, 2023
    1,298  Views

    Popular Salesforce Videos

    Get a Complete View of Salesforce Data with MongoDB

    Get a Complete View of Salesforce Data with MongoDB

    Video in Data, Salesforce Training

    Teri will show you how you can incorporate Salesforce (relational data) into a MongoDB collection (non-relational data) to give your customers a unified customer experience.…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Data, Salesforce Video
    Rupal Kakkar Jul 2, 2021
    1,560  Views
    Streamline Sales Goals and Add Value to Your B2B Organization With Salesforce Marketing Automation

    Streamline Sales Goals and Add Value to Your B2B Organization With Salesforce Marketing Automation

    Video in Salesforce Products

    Salesforce Marketing Automation enables businesses to automate marketing processes, track customer engagement while delivering personalized experiences to each customer. With it, you can streamline and…

    Salesforce Training, Salesforce Developer, Customer Engagement, Salesforce Video, Salesforce Learning
    Kcloud Dec 16, 2020
    2,304  Views
    Done With Training But Not Getting Salesforce Interview Calls, What To Do?

    Done With Training But Not Getting Salesforce Interview Calls, What To Do?

    Video in Salesforce Stories, Salesforce Training

    To sum up, choosing a Salesforce Career will be a better option than any other profession seeing the opportunities that it is creating in the…

    Salesforce Training, Salesforce Jobs, salesforce, Salesforce Video, Salesforce Career
    Jogender May 13, 2022
    1,669  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.