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

    Popular Salesforce Blogs

    Populating Salesforce Data into a Table element

    Blog in Data

    Every product is investing huge effort in creating a nice user interface, making it “sexy” and inviting. There is no doubt that customers and service…

    Salesforce Data, Salesforce Data Insertion
    Ori Oct 24, 2017
    4,517  Views
    How can organizations benefit from sales cloud implementation?

    How can Organizations Benefit From Salesforce Sales Cloud Implementation

    Blog in Salesforce Cloud Platform

    Businesses today, irrespective of their scope or size need a feasible platform to pull through the fierce marketplace competition, nurture the existing customers, and acquire…

    Customer Experience, Customer Experiences, Customer Journeys, Customer Loyalty, marketing cloud and sales cloud integration
    Carol Mar 6, 2023
    2,081  Views
    What are Campaigns in Salesforce?

    What are Campaigns in Salesforce in 2023?

    Blog in Others

    One of the most important features of Salesforce is its Campaign feature, which allows businesses to plan, execute, and track marketing campaigns. A campaign in…

    Apps, Campaign Field History, Campaign Hierarchies, Campaign Member, Campaign Members
    Nikhil Kumar Mar 17, 2023
    1,891  Views

    Popular Salesforce Videos

    Hello (Salesforce) World - An introduction to Tableau Developer

    Hello (Salesforce) World - An introduction to Tableau Developer

    Video in Salesforce Products

    Hello, Salesforce world! Curious about Tableau (the newest member of the Salesforce family), our developer platform and suite of developer tools available? Whether you are…

    Salesforce Training, salesforce, Salesforce Developers, Salesforce Video, Tableau
    Jogender Jun 22, 2020
    1,481  Views
    Salesforce Trailhead - Control Access to Fields

    Salesforce Trailhead - Control Access to Fields

    Video in Trailhead

    In this video, Your Coding Buddy covers how to control access to fields in Salesforce Trailhead. He explains that this is important for keeping data…

    Salesforce Training, Salesforce Tutorial, salesforce, Trailhead, Salesforce Trailhead
    Tulika Wadhwani Nov 16, 2022
    1,941  Views
    How To Use Dynamic Prefill Link of Formstack | Learn Salesforce Series by Algoworks

    How To Use Dynamic Prefill Link of Formstack | Learn Salesforce Series by Algoworks

    Video in Salesforce Training

    Learn how to use ‘Dynamic Prefill Link’ of Formstack in 4 easy steps! 1. Introduction Short introduction of FormStack and its uses. 2. The need…

    Salesforce Development, salesforce, salesforce services, Salesforce Cloud, SFDC
    Algoworks Aug 25, 2020
    3,049  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.