Salesforce Rest API create account












1















We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?










share|improve this question





























    1















    We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?










    share|improve this question



























      1












      1








      1


      1






      We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?










      share|improve this question
















      We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?







      apex rest-api api bulk-api website-integration






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 23 at 8:42









      Oleksandr Berehovskyi

      10.2k32238




      10.2k32238










      asked Jan 23 at 8:02









      degmodegmo

      325




      325






















          1 Answer
          1






          active

          oldest

          votes


















          3














          yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.





          you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:



          @RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
          global with sharing class MyRestResource {

          @HttpPost
          global static String doPost(String lastName) {
          Contact cont = new Contact(
          LastName = lastName
          );
          insert cont;
          cont = [
          select Id, LongContactId__c // query all needed fields to be returned on insert call
          from Contact
          where Id = :cont.Id
          limit 1
          ];
          return cont;
          }
          }


          in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/






          share|improve this answer


























          • Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

            – degmo
            Jan 24 at 17:53











          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%2f247648%2fsalesforce-rest-api-create-account%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









          3














          yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.





          you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:



          @RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
          global with sharing class MyRestResource {

          @HttpPost
          global static String doPost(String lastName) {
          Contact cont = new Contact(
          LastName = lastName
          );
          insert cont;
          cont = [
          select Id, LongContactId__c // query all needed fields to be returned on insert call
          from Contact
          where Id = :cont.Id
          limit 1
          ];
          return cont;
          }
          }


          in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/






          share|improve this answer


























          • Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

            – degmo
            Jan 24 at 17:53
















          3














          yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.





          you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:



          @RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
          global with sharing class MyRestResource {

          @HttpPost
          global static String doPost(String lastName) {
          Contact cont = new Contact(
          LastName = lastName
          );
          insert cont;
          cont = [
          select Id, LongContactId__c // query all needed fields to be returned on insert call
          from Contact
          where Id = :cont.Id
          limit 1
          ];
          return cont;
          }
          }


          in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/






          share|improve this answer


























          • Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

            – degmo
            Jan 24 at 17:53














          3












          3








          3







          yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.





          you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:



          @RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
          global with sharing class MyRestResource {

          @HttpPost
          global static String doPost(String lastName) {
          Contact cont = new Contact(
          LastName = lastName
          );
          insert cont;
          cont = [
          select Id, LongContactId__c // query all needed fields to be returned on insert call
          from Contact
          where Id = :cont.Id
          limit 1
          ];
          return cont;
          }
          }


          in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/






          share|improve this answer















          yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.





          you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:



          @RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
          global with sharing class MyRestResource {

          @HttpPost
          global static String doPost(String lastName) {
          Contact cont = new Contact(
          LastName = lastName
          );
          insert cont;
          cont = [
          select Id, LongContactId__c // query all needed fields to be returned on insert call
          from Contact
          where Id = :cont.Id
          limit 1
          ];
          return cont;
          }
          }


          in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 23 at 8:43

























          answered Jan 23 at 8:11









          Oleksandr BerehovskyiOleksandr Berehovskyi

          10.2k32238




          10.2k32238













          • Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

            – degmo
            Jan 24 at 17:53



















          • Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

            – degmo
            Jan 24 at 17:53

















          Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

          – degmo
          Jan 24 at 17:53





          Thanks Oleksandr, I was able to solve this via the APEX Rest API as you suggested. Much appreciated.

          – degmo
          Jan 24 at 17:53


















          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%2f247648%2fsalesforce-rest-api-create-account%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

          Mario Kart Wii

          What does “Dominus providebit” mean?

          Antonio Litta Visconti Arese