+ Start a Discussion
ShikibuShikibu 

save button for a new record ignores retURL parameter?

I wonder if this is a bug? I am having the same trouble discussed here. The following formula, as an "onclick javascript" custom button, correctly opens and prepopulates a new purchase_items__c, but when I press "save", I am taken to the new item rather than to the containing purchase order.

 

I'm sure that the retURL is correct, because the cancel button does take me back to the purchase order.

 

 

Here's the formula (I added spaces here for readability; it seems they must be removed for the formula to work):

navigateToUrl('{!URLFOR($Action.SFDC_Purchase_Items__c.New,null,

[retURL=URLFOR($Action.SFDC_Purchase_Order__c.View,SFDC_Purchase_Order__c.Id),

CF00N200000014eaJ=SFDC_Purchase_Order__c.Name,

CF00N200000014eaJ_lkid=SFDC_Purchase_Order__c.Id]

)}')

 

 

 

Message Edited by Shikibu on 08-20-2009 12:39 PM
Best Answer chosen by Admin (Salesforce Developers) 
ShikibuShikibu

ah, finally figured it out: retURL applies to cancel or edit, but you also need a saveURL to determine navigation following a save (remove spaces and newlines before using this; added only for clarity):

 

 




navigateToUrl('{
!URLFOR($Action.SFDC_Purchase_Items__c.New,
null,
[retURL=URLFOR($Action.SFDC_Purchase_Order__c.View,SFDC_Purchase_Order__c.Id),
saveURL=URLFOR($Action.SFDC_Purchase_Order__c.View,SFDC_Purchase_Order__c.Id),
CF00N200000014eaJ=SFDC_Purchase_Order__c.Name,
CF00N200000014eaJ_lkid=SFDC_Purchase_Order__c.Id])
}')

 

 

 

Message Edited by Shikibu on 08-20-2009 01:05 PM

All Answers

ShikibuShikibu

ah, finally figured it out: retURL applies to cancel or edit, but you also need a saveURL to determine navigation following a save (remove spaces and newlines before using this; added only for clarity):

 

 




navigateToUrl('{
!URLFOR($Action.SFDC_Purchase_Items__c.New,
null,
[retURL=URLFOR($Action.SFDC_Purchase_Order__c.View,SFDC_Purchase_Order__c.Id),
saveURL=URLFOR($Action.SFDC_Purchase_Order__c.View,SFDC_Purchase_Order__c.Id),
CF00N200000014eaJ=SFDC_Purchase_Order__c.Name,
CF00N200000014eaJ_lkid=SFDC_Purchase_Order__c.Id])
}')

 

 

 

Message Edited by Shikibu on 08-20-2009 01:05 PM
This was selected as the best answer
ShikibuShikibu

Really, I think that the reason so many people struggle with this is that salesforce has not documented how to construct urls.

 

I can't find any docs for "saveURL", not in VF Guide, nor in online help. Searching forums finds lots of people struggling.

 

Salesforce, can you document this? For instance, in my URLFOR above, I used some parameters like this (which I inferred from clicking the standard "new" button on related list): CF00N200000014eaJ.

 

Is that a valid practice?

TehNrdTehNrd

There is also inconsistent behavior across different objects. retUrl works for saves and cancel on the Task object (maybe all standard objects, I don't know) but on custom objects you must use saveURL and retURL.

David SchachDavid Schach

Salesforce won't document this because it's not officially supported.  (That said, I feel your pain.)