+ Start a Discussion
heiriticheiritic 

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,
[retURL=URLFOR($Action.Opportunity.View,Opportunity.Id)],true)}";

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.
JTecJTec
You can set the saveURL. In your Code bould be:


Code:
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

heiriticheiritic
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. www.yahoo.com. 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 ?


thanx
sfdcfoxsfdcfox
Just tested this myself. You can do so with:

Code:
{!URLFOR($Action.Case.Edit,Case.Id,[retURL="http%3A//www.yahoo.com/"])}
Just include the "protocol" ("http%3A//") as part of the retURL, and it'll make you leave Salesforce.

~ sfdcfox ~
 

heiriticheiritic

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//www.yahoo.com/"],true)}";

</script>

 

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

https://na5.salesforce.com/50070000003T7Fs/http%3A//www.yahoo.com/

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?

 

 

thanx,

 

edwin 

heiriticheiritic
At last I have figured it out..Thanx for everyone I got the answer. here is the code that is successful :
Code:
 window.parent.location.href = "{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR("http://www.yahoo.com/", 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?
 
thanx
heiriticheiritic
I want to add that I have tried to open a new window. I have used window.open() but it seems it doesn't happen to open a new window
Here is my code :Code:
window.open("{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR("http://www.yahoo.com/", 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?
heiriticheiritic
Code:
window.open("{!URLFOR($Action.Opportunity.Edit , Opportunity.Id , [saveURL=URLFOR("http://www.yahoo.com/", 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.
 
thanx
heiriticheiritic
I have figured it out.now window.open() 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. www.yahoo.com. Can salesforce manage that? Need advice, I appreciate it.
heiriticheiritic
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 window.open 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...

 

thanx,

edwin

knicholsknichols
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.