2

I am attempting to use a custom VF page that has some limited form data.

It uses a standard controller, and the command button I use for the {!save} action is pointing directly at the standard controller function.

However, when I pass a "saveURL" and or a "cancelURL" - neither of them are respected.

Do these options only work on standard page layouts?

I shouldn't have to write apex for a simple window redirect :(

EDIT: Here is what the page looks like: The user is navigated here by a window.location update on a previous page that that looks like the following:

...location = "/apex/shipment_quickNew?saveURL=" + mySaveURL + "&cancelURL=" + myCancelURL;

--

< apex:page standardController="Shipment__c" extensions="shipment_int">


<script>
function setWarehouseSelection(){
$('.Shipment__c_Warehouse__c').eq(1).val(
    $('.Shipment__c_Warehouse__c').eq(0).val()
);
}
 </script>

<div id="shipment_pageBlock">
    <apex:pageBlock title="Quick Info" id="shipment_pageBlock">      
        <apex:pageMessages ></apex:pageMessages>
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save"/>
            <apex:commandButton action="{!cancel}" value="Cancel"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection collapsible="false" columns="2">

            <apex:pageBlockSectionItem >
                <apex:outputLabel value="{!$ObjectType.Shipment__c.Fields.Warehouse__c.Label}"></apex:outputLabel>
                <apex:outputPanel >
                    <span class="scm_requiredMark">*</span>
                    <apex:selectList value="{!Shipment__c.Warehouse__c}" multiselect="false" size="1">
                        <apex:selectOptions value="{!warehouseOptions}"></apex:selectOptions>
                    </apex:selectList>
                </apex:outputPanel>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</div>

  • How are you using your action method , are you using the URLFOR or harding the save and ret in your controller.Can you post your action method / the <apex:commandbutton/link action="{}"/> line in the VF page? – Rao Jul 19 '13 at 23:31
  • retURL is usually your cancel URL, I.e. where you're redirected if you hit Cancel – techtrekker Jul 21 '13 at 15:46
  • I'm not using an action method, I'm just passing the params in the URL via a javascript string construction. The only reason I would use a page reference is to maintain the view state of the controller - but since the page is a standard page - then I have no way to maintain a view state - and thus no reason to add the overhead of those silly page references – Jay-Nicolas Hackleman Jul 22 '13 at 17:21
  • 1
    can you please paste how you are constructing the mySaveURL and mycancelURL in the JS – Rao Jul 22 '13 at 18:34
  • It's possible your saveUrl and cancelUrl are malformed. Can you post an example generated url with params so we can see? – Tim Smith Aug 7 '13 at 6:57
1

I've never tried but you might override the retURL by your mySaveURL/myCancelURL in javascript on 'onclick'.

<apex:commandButton action="{!save}" onclick="javascript: window.location.assign(window.location.href+='&retURL='+mySaveURL);" />

Try to play with that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.