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
Dimitar Dimitrov 34Dimitar Dimitrov 34 

Return to previous page from "Create new sObject" page.

Hi all and Happy new year.

I had this task to create a custom Related list on the Account Page Layout with Visualforce and it all works fine. I've got all the records that i need and all the required fields and of course "New Project" button.

New Project button

However the only issue is that when i added the "New BD Project" button, when the new page is opened and the user change his mind and press "Cancel" it returns to the Visualforce page only, not to the Account Page Layout.

Cancel

I tried different solution, but i could not make it work.
Here is the commandlink button
<div style="margin-left: 30%;">
<apex:commandLink value="New BD Project" action="       {!URLFOR($Action.BD_Project__c.New)}" target="_parent"     styleClass="btn" style="text-      decoration:none;padding:4px;"/>
</div>

I found the whole Visualforce page and Controller in another solution which was for Contact Related list and i modified it to fit my requirements. The only change is that in the working Contact solution(where when you press cancel it returns you to the previous page) is that the code for the New Object is in the Controler:
 
public pageReference newContact()
{
pageReference pageRef = new pageReference(URL.getSalesforceBaseUrl().toExternalForm() + '/003/e?&retURL=' + accounts.id);
return pageRef;
}

Did any of you guys had a similar issue and found a solution.

Kind regards,
Dimitar
 

Here is the controller and the Visualforce that i'm using.:


 
Best Answer chosen by Dimitar Dimitrov 34
Dushyant SonwarDushyant Sonwar
Dimitar,

You need to set parameter in your URLFOR method.

https://help.salesforce.com/articleView?id=custom_links_constructing.htm&type=5 (https://help.salesforce.com/articleView?id=custom_links_constructing.htm&type=5)
 
{!URLFOR( $Action.BD_Project__c.New, null,[retURL= 'set where you want to redirect'])}

 

All Answers

movie apkmovie apk
Thanks for this tips, I used of my own blog check out :- https://www.typhoontv.me/
Dushyant SonwarDushyant Sonwar
Dimitar,

You need to set parameter in your URLFOR method.

https://help.salesforce.com/articleView?id=custom_links_constructing.htm&type=5 (https://help.salesforce.com/articleView?id=custom_links_constructing.htm&type=5)
 
{!URLFOR( $Action.BD_Project__c.New, null,[retURL= 'set where you want to redirect'])}

 
This was selected as the best answer
Dimitar Dimitrov 34Dimitar Dimitrov 34

Dushyant,

thank you for your reply,

I managed to make it work, here is the code:
 

action="{!URLFOR($Action.BD_Project__c.New, null,[retURL=URLFOR($Action.Account.View,accounts.Id)])}"

Kind regards,
Dimitar

 


 

YD98YD98
It's really nice. I need to try this on my app site (https://www.unlockmytvapp.com). Do you think it will work? anyway thanks!