Rest service class Is it possible to redirect to a record detailed page












1















In the rest service class, Is it possible to redirect to a record detail page of a object using an record?(assume that the record will get in class) see below code



@RestResource(urlmapping = '/test/*')

global without sharing class test {

@HttpPost
global static String doPost() {

RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Blob body = req.requestBody;

contact c = new contact();
c.lastname = 'Test';
insert c;
return null;
}


Is it possible to Redirect contact record detail page, please any one help on this.










share|improve this question





























    1















    In the rest service class, Is it possible to redirect to a record detail page of a object using an record?(assume that the record will get in class) see below code



    @RestResource(urlmapping = '/test/*')

    global without sharing class test {

    @HttpPost
    global static String doPost() {

    RestRequest req = RestContext.request;
    RestResponse res = RestContext.response;
    Blob body = req.requestBody;

    contact c = new contact();
    c.lastname = 'Test';
    insert c;
    return null;
    }


    Is it possible to Redirect contact record detail page, please any one help on this.










    share|improve this question



























      1












      1








      1








      In the rest service class, Is it possible to redirect to a record detail page of a object using an record?(assume that the record will get in class) see below code



      @RestResource(urlmapping = '/test/*')

      global without sharing class test {

      @HttpPost
      global static String doPost() {

      RestRequest req = RestContext.request;
      RestResponse res = RestContext.response;
      Blob body = req.requestBody;

      contact c = new contact();
      c.lastname = 'Test';
      insert c;
      return null;
      }


      Is it possible to Redirect contact record detail page, please any one help on this.










      share|improve this question
















      In the rest service class, Is it possible to redirect to a record detail page of a object using an record?(assume that the record will get in class) see below code



      @RestResource(urlmapping = '/test/*')

      global without sharing class test {

      @HttpPost
      global static String doPost() {

      RestRequest req = RestContext.request;
      RestResponse res = RestContext.response;
      Blob body = req.requestBody;

      contact c = new contact();
      c.lastname = 'Test';
      insert c;
      return null;
      }


      Is it possible to Redirect contact record detail page, please any one help on this.







      rest-api






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 18 '18 at 9:41









      rahul gawale

      825317




      825317










      asked Nov 18 '18 at 9:22









      Test userADG23Test userADG23

      266




      266






















          1 Answer
          1






          active

          oldest

          votes


















          6














          You can generate the link for your record and can use it for redirection. Try something like this in your code.



          String RecordId = c.Id;
          String Recordlink = URL.getSalesforceBaseUrl().toExternalForm()+'/'+RecordId;


          To answer your question for the redirection to a record detail page little vague. You actually can't use the REST service to redirect to a page. All you can get from a service is a response. Response could be anything. If you are returning a link to a record detail page it will still be a response and the caller will decide if you have to redirect now or not.




          So by using above snippet you can generate a link but can't achieve a
          redirection directly. Its the caller's job not the service.







          share|improve this answer


























          • let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

            – SFDCLearneR
            Nov 18 '18 at 10:28













          • @ sfdcLynx please see above comment and reply me

            – Test userADG23
            Nov 18 '18 at 10:29








          • 1





            @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

            – sfdcLynx
            Nov 18 '18 at 10:37











          • @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

            – Test userADG23
            Nov 19 '18 at 10:37











          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%2f239741%2frest-service-class-is-it-possible-to-redirect-to-a-record-detailed-page%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









          6














          You can generate the link for your record and can use it for redirection. Try something like this in your code.



          String RecordId = c.Id;
          String Recordlink = URL.getSalesforceBaseUrl().toExternalForm()+'/'+RecordId;


          To answer your question for the redirection to a record detail page little vague. You actually can't use the REST service to redirect to a page. All you can get from a service is a response. Response could be anything. If you are returning a link to a record detail page it will still be a response and the caller will decide if you have to redirect now or not.




          So by using above snippet you can generate a link but can't achieve a
          redirection directly. Its the caller's job not the service.







          share|improve this answer


























          • let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

            – SFDCLearneR
            Nov 18 '18 at 10:28













          • @ sfdcLynx please see above comment and reply me

            – Test userADG23
            Nov 18 '18 at 10:29








          • 1





            @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

            – sfdcLynx
            Nov 18 '18 at 10:37











          • @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

            – Test userADG23
            Nov 19 '18 at 10:37
















          6














          You can generate the link for your record and can use it for redirection. Try something like this in your code.



          String RecordId = c.Id;
          String Recordlink = URL.getSalesforceBaseUrl().toExternalForm()+'/'+RecordId;


          To answer your question for the redirection to a record detail page little vague. You actually can't use the REST service to redirect to a page. All you can get from a service is a response. Response could be anything. If you are returning a link to a record detail page it will still be a response and the caller will decide if you have to redirect now or not.




          So by using above snippet you can generate a link but can't achieve a
          redirection directly. Its the caller's job not the service.







          share|improve this answer


























          • let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

            – SFDCLearneR
            Nov 18 '18 at 10:28













          • @ sfdcLynx please see above comment and reply me

            – Test userADG23
            Nov 18 '18 at 10:29








          • 1





            @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

            – sfdcLynx
            Nov 18 '18 at 10:37











          • @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

            – Test userADG23
            Nov 19 '18 at 10:37














          6












          6








          6







          You can generate the link for your record and can use it for redirection. Try something like this in your code.



          String RecordId = c.Id;
          String Recordlink = URL.getSalesforceBaseUrl().toExternalForm()+'/'+RecordId;


          To answer your question for the redirection to a record detail page little vague. You actually can't use the REST service to redirect to a page. All you can get from a service is a response. Response could be anything. If you are returning a link to a record detail page it will still be a response and the caller will decide if you have to redirect now or not.




          So by using above snippet you can generate a link but can't achieve a
          redirection directly. Its the caller's job not the service.







          share|improve this answer















          You can generate the link for your record and can use it for redirection. Try something like this in your code.



          String RecordId = c.Id;
          String Recordlink = URL.getSalesforceBaseUrl().toExternalForm()+'/'+RecordId;


          To answer your question for the redirection to a record detail page little vague. You actually can't use the REST service to redirect to a page. All you can get from a service is a response. Response could be anything. If you are returning a link to a record detail page it will still be a response and the caller will decide if you have to redirect now or not.




          So by using above snippet you can generate a link but can't achieve a
          redirection directly. Its the caller's job not the service.








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 18 '18 at 10:15

























          answered Nov 18 '18 at 9:59









          sfdcLynxsfdcLynx

          1356




          1356













          • let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

            – SFDCLearneR
            Nov 18 '18 at 10:28













          • @ sfdcLynx please see above comment and reply me

            – Test userADG23
            Nov 18 '18 at 10:29








          • 1





            @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

            – sfdcLynx
            Nov 18 '18 at 10:37











          • @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

            – Test userADG23
            Nov 19 '18 at 10:37



















          • let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

            – SFDCLearneR
            Nov 18 '18 at 10:28













          • @ sfdcLynx please see above comment and reply me

            – Test userADG23
            Nov 18 '18 at 10:29








          • 1





            @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

            – sfdcLynx
            Nov 18 '18 at 10:37











          • @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

            – Test userADG23
            Nov 19 '18 at 10:37

















          let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

          – SFDCLearneR
          Nov 18 '18 at 10:28







          let me explain clearly. I have implemented rest service and accessing API via force.com site and external system invoking this service with site URL. Whenever external system send the response with service URL we are creating or updating few objects. After execution is completed then it should be redirect to Opportunity or Contact Detail page. Any solution for this requirement? Please let me know on this.

          – SFDCLearneR
          Nov 18 '18 at 10:28















          @ sfdcLynx please see above comment and reply me

          – Test userADG23
          Nov 18 '18 at 10:29







          @ sfdcLynx please see above comment and reply me

          – Test userADG23
          Nov 18 '18 at 10:29






          1




          1





          @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

          – sfdcLynx
          Nov 18 '18 at 10:37





          @SFDCLearneR implementation will remain same. Your service in the force.com platform should generate a URL as I showed you above in the snippet. You can return this generated RecordLink as a response for your external system. And, once you received a response from service. You can redirect to that link. But the service can't do something like this that you update some records and then automatically redirected to some url. This is not possible with service or you can say not the function of any service.

          – sfdcLynx
          Nov 18 '18 at 10:37













          @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

          – Test userADG23
          Nov 19 '18 at 10:37





          @sfdcLynx Thank you for your help. I understand that we can't able to return to salesforce record detail page after DML operation in REST API. We can able to do this in SOAP API? Can you please let me know on this

          – Test userADG23
          Nov 19 '18 at 10:37


















          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%2f239741%2frest-service-class-is-it-possible-to-redirect-to-a-record-detailed-page%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







          這個網誌中的熱門文章

          Hercules Kyvelos

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud