Execute Apex on Record Load Trigger?












2















I am working with a custom rest api that connects to our billing service, We are wanting to, when we load a salesforce record, for it to execute an apex script. We want to use that script to query the api and check for updated agreements records. We don't control the billing service so we have no way of doing the reverse.



The only other option I can think of is to create a custom button and use it to execute the apex, but that just creates an extra step and that is just to much work for my colleagues.










share|improve this question





























    2















    I am working with a custom rest api that connects to our billing service, We are wanting to, when we load a salesforce record, for it to execute an apex script. We want to use that script to query the api and check for updated agreements records. We don't control the billing service so we have no way of doing the reverse.



    The only other option I can think of is to create a custom button and use it to execute the apex, but that just creates an extra step and that is just to much work for my colleagues.










    share|improve this question



























      2












      2








      2








      I am working with a custom rest api that connects to our billing service, We are wanting to, when we load a salesforce record, for it to execute an apex script. We want to use that script to query the api and check for updated agreements records. We don't control the billing service so we have no way of doing the reverse.



      The only other option I can think of is to create a custom button and use it to execute the apex, but that just creates an extra step and that is just to much work for my colleagues.










      share|improve this question
















      I am working with a custom rest api that connects to our billing service, We are wanting to, when we load a salesforce record, for it to execute an apex script. We want to use that script to query the api and check for updated agreements records. We don't control the billing service so we have no way of doing the reverse.



      The only other option I can think of is to create a custom button and use it to execute the apex, but that just creates an extra step and that is just to much work for my colleagues.







      apex trigger rest-api






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 10 hours ago









      Logie C

      195




      195










      asked 11 hours ago









      jeremiahjeremiah

      459




      459






















          1 Answer
          1






          active

          oldest

          votes


















          4














          Triggers don't work like that, unfortunately.



          Triggers are a database construct that allow you to perform work when there is a change to the database (insert, update, delete, undelete), and reading a record from a database generally doesn't cause any change.



          Instead, what you'll probably want to look into is including an inline visualforce page in your page layout, or creating a custom lightning component to add to the page layout (depending on whether you're using classic or LEX). Both will cause code to be executed (at some point in time during the page rendering process, every time the record is viewed), which you should be able to piggyback off of to do your callout.






          share|improve this answer


























          • Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

            – jeremiah
            10 hours ago













          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          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%2f253702%2fexecute-apex-on-record-load-trigger%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          Triggers don't work like that, unfortunately.



          Triggers are a database construct that allow you to perform work when there is a change to the database (insert, update, delete, undelete), and reading a record from a database generally doesn't cause any change.



          Instead, what you'll probably want to look into is including an inline visualforce page in your page layout, or creating a custom lightning component to add to the page layout (depending on whether you're using classic or LEX). Both will cause code to be executed (at some point in time during the page rendering process, every time the record is viewed), which you should be able to piggyback off of to do your callout.






          share|improve this answer


























          • Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

            – jeremiah
            10 hours ago


















          4














          Triggers don't work like that, unfortunately.



          Triggers are a database construct that allow you to perform work when there is a change to the database (insert, update, delete, undelete), and reading a record from a database generally doesn't cause any change.



          Instead, what you'll probably want to look into is including an inline visualforce page in your page layout, or creating a custom lightning component to add to the page layout (depending on whether you're using classic or LEX). Both will cause code to be executed (at some point in time during the page rendering process, every time the record is viewed), which you should be able to piggyback off of to do your callout.






          share|improve this answer


























          • Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

            – jeremiah
            10 hours ago
















          4












          4








          4







          Triggers don't work like that, unfortunately.



          Triggers are a database construct that allow you to perform work when there is a change to the database (insert, update, delete, undelete), and reading a record from a database generally doesn't cause any change.



          Instead, what you'll probably want to look into is including an inline visualforce page in your page layout, or creating a custom lightning component to add to the page layout (depending on whether you're using classic or LEX). Both will cause code to be executed (at some point in time during the page rendering process, every time the record is viewed), which you should be able to piggyback off of to do your callout.






          share|improve this answer















          Triggers don't work like that, unfortunately.



          Triggers are a database construct that allow you to perform work when there is a change to the database (insert, update, delete, undelete), and reading a record from a database generally doesn't cause any change.



          Instead, what you'll probably want to look into is including an inline visualforce page in your page layout, or creating a custom lightning component to add to the page layout (depending on whether you're using classic or LEX). Both will cause code to be executed (at some point in time during the page rendering process, every time the record is viewed), which you should be able to piggyback off of to do your callout.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 9 hours ago

























          answered 10 hours ago









          Derek FDerek F

          20.4k42252




          20.4k42252













          • Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

            – jeremiah
            10 hours ago





















          • Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

            – jeremiah
            10 hours ago



















          Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

          – jeremiah
          10 hours ago







          Thanks, I will look into that. If that is the only real way to do what I want then I will just create a custom visualforce page. It's extra work, but if it needs to happen that is what I will do. Thanks Derek!

          – jeremiah
          10 hours ago




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f253702%2fexecute-apex-on-record-load-trigger%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          數位音樂下載

          When can things happen in Etherscan, such as the picture below?

          格利澤436b