retURL in URLFOR not redirecting correctly











up vote
0
down vote

favorite












I have a VF page that is embedded inline on a custom object page layout section. In the VF page, I used a command button to redirect to another custom object using the URLFOR New Action.



<apex:commandButton onclick="window.parent.location.replace('{!URLFOR($Action.Design__c.New)}');" value="Add Design" rendered="{!IF(designId == null, true, false)}" />


This works and opens the custom object in the create 'New' record mode. However, if I click 'Cancel' the retURL opens my VF page directly and not inline on the custom object page layout, which is very bad. I displays the VF page with no way to get back to the Salesforce UI without hitting the back button.



How can I set the retURL probably in the URLFOR method so when the user clicks cancel that it will redirect them back to the correct page?










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have a VF page that is embedded inline on a custom object page layout section. In the VF page, I used a command button to redirect to another custom object using the URLFOR New Action.



    <apex:commandButton onclick="window.parent.location.replace('{!URLFOR($Action.Design__c.New)}');" value="Add Design" rendered="{!IF(designId == null, true, false)}" />


    This works and opens the custom object in the create 'New' record mode. However, if I click 'Cancel' the retURL opens my VF page directly and not inline on the custom object page layout, which is very bad. I displays the VF page with no way to get back to the Salesforce UI without hitting the back button.



    How can I set the retURL probably in the URLFOR method so when the user clicks cancel that it will redirect them back to the correct page?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a VF page that is embedded inline on a custom object page layout section. In the VF page, I used a command button to redirect to another custom object using the URLFOR New Action.



      <apex:commandButton onclick="window.parent.location.replace('{!URLFOR($Action.Design__c.New)}');" value="Add Design" rendered="{!IF(designId == null, true, false)}" />


      This works and opens the custom object in the create 'New' record mode. However, if I click 'Cancel' the retURL opens my VF page directly and not inline on the custom object page layout, which is very bad. I displays the VF page with no way to get back to the Salesforce UI without hitting the back button.



      How can I set the retURL probably in the URLFOR method so when the user clicks cancel that it will redirect them back to the correct page?










      share|improve this question















      I have a VF page that is embedded inline on a custom object page layout section. In the VF page, I used a command button to redirect to another custom object using the URLFOR New Action.



      <apex:commandButton onclick="window.parent.location.replace('{!URLFOR($Action.Design__c.New)}');" value="Add Design" rendered="{!IF(designId == null, true, false)}" />


      This works and opens the custom object in the create 'New' record mode. However, if I click 'Cancel' the retURL opens my VF page directly and not inline on the custom object page layout, which is very bad. I displays the VF page with no way to get back to the Salesforce UI without hitting the back button.



      How can I set the retURL probably in the URLFOR method so when the user clicks cancel that it will redirect them back to the correct page?







      salesforce apex-code visualforce






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 6:38









      Cœur

      17k9102140




      17k9102140










      asked Apr 30 '13 at 17:07









      Dman100

      45211641




      45211641
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          You should be able to pass in a value for retURL (as well as any other additional URL parameters) along with URLFOR by doing something like:



          {!URLFOR($Action.Design__c.New, null, [retURL=SOMEOBJECTID])}


          You'll obviously have to replace "SOMEOBJECTID" with the Id of the custom object record you were originally viewing.



          Update:



          Additional information on the full usage of URLFOR can be found on this blog entry.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f16305363%2freturl-in-urlfor-not-redirecting-correctly%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








            up vote
            0
            down vote



            accepted










            You should be able to pass in a value for retURL (as well as any other additional URL parameters) along with URLFOR by doing something like:



            {!URLFOR($Action.Design__c.New, null, [retURL=SOMEOBJECTID])}


            You'll obviously have to replace "SOMEOBJECTID" with the Id of the custom object record you were originally viewing.



            Update:



            Additional information on the full usage of URLFOR can be found on this blog entry.






            share|improve this answer



























              up vote
              0
              down vote



              accepted










              You should be able to pass in a value for retURL (as well as any other additional URL parameters) along with URLFOR by doing something like:



              {!URLFOR($Action.Design__c.New, null, [retURL=SOMEOBJECTID])}


              You'll obviously have to replace "SOMEOBJECTID" with the Id of the custom object record you were originally viewing.



              Update:



              Additional information on the full usage of URLFOR can be found on this blog entry.






              share|improve this answer

























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                You should be able to pass in a value for retURL (as well as any other additional URL parameters) along with URLFOR by doing something like:



                {!URLFOR($Action.Design__c.New, null, [retURL=SOMEOBJECTID])}


                You'll obviously have to replace "SOMEOBJECTID" with the Id of the custom object record you were originally viewing.



                Update:



                Additional information on the full usage of URLFOR can be found on this blog entry.






                share|improve this answer














                You should be able to pass in a value for retURL (as well as any other additional URL parameters) along with URLFOR by doing something like:



                {!URLFOR($Action.Design__c.New, null, [retURL=SOMEOBJECTID])}


                You'll obviously have to replace "SOMEOBJECTID" with the Id of the custom object record you were originally viewing.



                Update:



                Additional information on the full usage of URLFOR can be found on this blog entry.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 30 '13 at 18:08

























                answered Apr 30 '13 at 18:03









                JCD

                2,11111325




                2,11111325






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16305363%2freturl-in-urlfor-not-redirecting-correctly%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

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python