Why do Apex classes have an API version

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












I am unsure why each class has an API version. I know during each release they have added functionality therefore previous versions would not support this but I feel there must be more of a reason.



I also assume API versions is how they deprecate things and add new functionality. Is it best practice to update a class to the newest API if it has no dependencies?










share|improve this question



























    up vote
    2
    down vote

    favorite












    I am unsure why each class has an API version. I know during each release they have added functionality therefore previous versions would not support this but I feel there must be more of a reason.



    I also assume API versions is how they deprecate things and add new functionality. Is it best practice to update a class to the newest API if it has no dependencies?










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I am unsure why each class has an API version. I know during each release they have added functionality therefore previous versions would not support this but I feel there must be more of a reason.



      I also assume API versions is how they deprecate things and add new functionality. Is it best practice to update a class to the newest API if it has no dependencies?










      share|improve this question













      I am unsure why each class has an API version. I know during each release they have added functionality therefore previous versions would not support this but I feel there must be more of a reason.



      I also assume API versions is how they deprecate things and add new functionality. Is it best practice to update a class to the newest API if it has no dependencies?







      apex api-version






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      M guy

      30619




      30619




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          8
          down vote



          accepted










          To put it simply: The API version decides a couple of things for the Apex class - what fields you can access on a particular object or how you can implement certain mechanics.



          And you're correct - API versions are used to introduce new features as well as deprecate old ones. Think of it as a way to decide what collection of functionality you want to use.



          What is the best practice is an entirely different question - but to give you a very basic idea for this: Different API versions can give you all kinds of weird errors and behavior. From my personal experience, it is best to upgrade your API versions from time to time, so you have a consistent and recent version over all your classes and throughout your org.



          See also:
          What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "459"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232081%2fwhy-do-apex-classes-have-an-api-version%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            8
            down vote



            accepted










            To put it simply: The API version decides a couple of things for the Apex class - what fields you can access on a particular object or how you can implement certain mechanics.



            And you're correct - API versions are used to introduce new features as well as deprecate old ones. Think of it as a way to decide what collection of functionality you want to use.



            What is the best practice is an entirely different question - but to give you a very basic idea for this: Different API versions can give you all kinds of weird errors and behavior. From my personal experience, it is best to upgrade your API versions from time to time, so you have a consistent and recent version over all your classes and throughout your org.



            See also:
            What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?






            share|improve this answer


























              up vote
              8
              down vote



              accepted










              To put it simply: The API version decides a couple of things for the Apex class - what fields you can access on a particular object or how you can implement certain mechanics.



              And you're correct - API versions are used to introduce new features as well as deprecate old ones. Think of it as a way to decide what collection of functionality you want to use.



              What is the best practice is an entirely different question - but to give you a very basic idea for this: Different API versions can give you all kinds of weird errors and behavior. From my personal experience, it is best to upgrade your API versions from time to time, so you have a consistent and recent version over all your classes and throughout your org.



              See also:
              What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?






              share|improve this answer
























                up vote
                8
                down vote



                accepted







                up vote
                8
                down vote



                accepted






                To put it simply: The API version decides a couple of things for the Apex class - what fields you can access on a particular object or how you can implement certain mechanics.



                And you're correct - API versions are used to introduce new features as well as deprecate old ones. Think of it as a way to decide what collection of functionality you want to use.



                What is the best practice is an entirely different question - but to give you a very basic idea for this: Different API versions can give you all kinds of weird errors and behavior. From my personal experience, it is best to upgrade your API versions from time to time, so you have a consistent and recent version over all your classes and throughout your org.



                See also:
                What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?






                share|improve this answer














                To put it simply: The API version decides a couple of things for the Apex class - what fields you can access on a particular object or how you can implement certain mechanics.



                And you're correct - API versions are used to introduce new features as well as deprecate old ones. Think of it as a way to decide what collection of functionality you want to use.



                What is the best practice is an entirely different question - but to give you a very basic idea for this: Different API versions can give you all kinds of weird errors and behavior. From my personal experience, it is best to upgrade your API versions from time to time, so you have a consistent and recent version over all your classes and throughout your org.



                See also:
                What are all of the reasons why Salesforce customers should upgrade the API version on their Apex classes, triggers, and pages?







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited yesterday

























                answered yesterday









                Semmel

                507315




                507315



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f232081%2fwhy-do-apex-classes-have-an-api-version%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    White Anglo-Saxon Protestant

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    One-line joke