function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

set retURL at URLFOR with link

I need help about setting link at URLFOR. Can salesforce do that? I want to use that scontrol when I click 'save' at opportunity and point it to another url. The use of URLFOR I know is with retURL :

window.parent.location.href="{! URLFOR($Action.Opportunity.Edit,Opportunity.Id,

I can't override button 'save', so I override button 'edit' at opportunity. If only I can use trigger and set url to location I want. Anyone has idea or suggestion? It would be appreciated.
You can set the saveURL. In your Code bould be:

window.parent.location.href="{! URLFOR($Action.Opportunity.Edit,Opportunity.Id,
[saveURL=URLFOR(..........), retURL=URLFOR($Action.Opportunity.View,Opportunity.Id)],true)}";

I hope this is of aid to you...

Message Edited by JTec on 08-14-2007 05:40 AM

Hm...I think it's different from what I want. Can I use URLFOR to set to another url other that salesforce? So when I click 'save' at opportunity, it will go to i.e. I think the saveURL and retURL just return the url to salesforce again. Is it true? Is there any method to do what I want to? I can't figure it out...Any assist ?

Just tested this myself. You can do so with:

Just include the "protocol" ("http%3A//") as part of the retURL, and it'll make you leave Salesforce.

~ sfdcfox ~


It's still not right in me. this is my full code :

<script type="text/javascript">
window.parent.location.href="{! URLFOR($Action.Opportunity.Edit,Opportunity.Id,[retURL="http%3A//"],true)}";



it leads me to a non-exist url. This is the url I get :

It looks like it still return to salesforce site..Is there something missing in my code? If I don't use 'true', it will loop forever. Any more ideas? Or can I use trigger and set the scontrol or url?






At last I have figured it out..Thanx for everyone I got the answer. here is the code that is successful :
 window.parent.location.href = "{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR("", null), retURL=URLFOR($Request.retURL, null,null,true)] ,true)}"; 

Thanx guys. But How if I want to open the url with new window? any suggestion?
I want to add that I have tried to open a new window. I have used but it seems it doesn't happen to open a new window
Here is my code :Code:"{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR("", null), retURL=URLFOR($Request.retURL, null,null,true)] ,true)}","","status=yes,height=200,width=300"; 

I have turned off my popup blocker too. Why it doesn't work? Any suggestions or advices?
Code:"{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR("", null), retURL=URLFOR($Request.retURL, null,null,true)] ,true)}","","status=yes,height=200,width=300"); 

here is the real code. the code before doesn't have the bracket at the end before the semicolon so don't be confuse with the code before.But it still doesn't want to open the new window..any advices?I appreciate that.
I have figured it is running properly. Maybe because I haven't refresh the window. Strange.....But What I want is when click save button at Opportunity,it will launch a new window and get the url i.e. Can salesforce manage that? Need advice, I appreciate it.
Here is the latest one that I have figured out but it is still not perfect for my need. Here is the code :Code:
window.parent.location.href="{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR( $SControl.InterruptNewAccountWithSetValue, null), retURL=URLFOR($Request.retURL,Opportunity.Id)] ,true)}"; 

It can launch to another url with new window after the click save. I use another scontrol that has in it so it will launch the new window. But Why does the first window become blank? It should go to Request.retURL right? Am I wrong? any advice would be appreciated. I'm so confused...




I'm having the same problem with the blank screen.  I'm not sure why it becomes blank when I open a new window....
Anesh MAnesh M

I found the following works just fine


<apex:commandButton value="Edit" onclick="window.parent.location.replace('{!URLFOR($Action.Opportunity.Edit, Opportunity.Id , [retURL=Opportunity.Id])}');"></apex:commandButton>

Ankita Agrawal 46Ankita Agrawal 46

Hello @Anesh M
Thank you for the solution you provided.
But its not opening the window in lightning theme. Please let me know how we can use this in lightning .

I want to open the edit page in lightning view and and redirectback it to the previous page.