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 to use save points in apex class while saving data and how to implement it?

    Tagged: Account, Database, Salesforce Apex, Salesforce Apex Class, Salesforce SOQL

    • Salesforce® Discussions

      How to use save points in apex class while saving data and how to implement it?

      Posted by Naman on April 30, 2016 at 6:07 PM

      How to use save points in apex class while saving data and how to implement it?

      Surbhi replied 9 years, 6 months ago 2 Members · 1 Reply
      • Account
      • Database
      • Salesforce Apex
      • Salesforce Apex Class
      • Salesforce SOQL
    • 1 Reply
    • Surbhi

      Member
      June 9, 2016 at 1:19 PM

      Hi Naman,

      Try using this approach, hope this will help you:

      Account a = new Account(Name = 'Abc');

      insert a;

      System.assertEquals(null, [SELECT AccountNumber FROM Account WHERE Id = :a.Id].
      AccountNumber);

      // Create a savepoint while AccountNumber is null
      Savepoint sp = Database.setSavepoint();

      // Change the account number
      a.AccountNumber = '123';
      update a;
      System.assertEquals('123', [SELECT AccountNumber FROM Account WHERE Id = :a.Id].
      AccountNumber);

      // Rollback to the previous null value
      Database.rollback(sp);
      System.assertEquals(null, [SELECT AccountNumber FROM Account WHERE Id = :a.Id].
      AccountNumber);

      Thanks

    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

    Salesforce Classic to Lightning Migration: Benefits and Best Practices

    Blog in Lightning

    Salesforce is a comprehensive CRM platform that delivers almost everything needed to manage business operations efficiently. It is a powerful toolset that enables top-level management…

    Automation Capabilities, Back-End Design, Best Practices, Boosted Productivity, Business Operations
    Carol May 29, 2023
    1,821  Views
    salesforce for small business

    Explore the Benefits of Salesforce for Small Businesses

    Blog in Salesforce, Salesforce Stories

    Salesforce is a CRM that brings companies and clients together. In today’s world when the technology has been so advanced, every business needs a platform…

    Artificial Inttelligence, Built-in-Intelligence, Business Process, CRM, Learning and Training
    krati vishnoi Apr 30, 2020
    3,729  Views

    What is Constructor in Apex Programming? | Salesforce Apex Guide

    Blog in Salesforce Apex

    In Apex programming, a Constructor is a unique code used to set up a newly created object. It is called right after the memory for…

    Apex Programming, API, Constructor Chaining, Constructor in Apex Programming, data
    Emizen Sep 12, 2022
    7,832  Views

    Popular Salesforce Videos

    How To Build Better Communities with Salesforce Lightning?

    How To Build Better Communities with Salesforce Lightning?

    Video in Lightning

    Learn how you can customize Salesforce Community Cloud to fit your needs with the Lightning Bolt framework, Lightning Components and Community Builder.

    Salesforce Online Training, Salesforce Developer, Salesforce Lightning Components, Salesforce Community, Salesforce Community Cloud
    Portia Feb 6, 2018
    1,708  Views
    Salesforce Training for Beginners | Salesforce Tutorial for Certification

    Salesforce Training for Beginners | Salesforce Tutorial for Certification

    Video in Salesforce Certifications

    Once upon a time, storage was a big problem, but the innovations in technology have solved this. We can say that Cloud computing is one…

    Salesforce Reports, Process Automation, Salesforce Administration Demo, Salesforce Training For Beginers, Salesforce Tutorial For Certification
    Shiv Kumar Sharma Jan 18, 2018
    2,002  Views
    Smart Merchandising with Salesforce Einstein AI

    Smart Merchandising with Salesforce Einstein AI

    Video in AI and ML, Salesforce Einstein

    Smart Merchandising is a holistic tool that magically combines rich insights from site-wide search, navigation, purchases, and the customer’s current session with strategic business goals.…

    Salesforce Training, Salesforce Video, Customers, Salesforce Learning, Business
    Algoworks Jun 30, 2021
    1,611  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

    © 2025 - 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.