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
SteveA101SteveA101 

Save and redirect button

Hi everyone,

Given the following example:

I'm on record A.  I go to a related list on Record A and click NEW which takes me to a junction object.  After I save the system takes me to the View screen of the junction object.  I would like the user to be taken back to the view screen of Record A.

After doing some research on the sfdc Answers community, it seems like I need to override the Save button with a custom VF page.  Anyone have any sample code I might use?  VF is completely new to me.  Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
jayjaysjayjays

Hi,

 

you can do this by creating a custom button (List Button) on the junction object to replace the standard 'New' button.  The trick is to pass the saveURL parameter in the url with the id of the current record id  (Record A in your case).

 

For example, If your Record A was of a Custom Object named Test__c then the url for the button would look something like;

 

/a00/e?retURL=%2F{!Test__c.id}&saveURL=%2F{!Test__c.id}

 

Don't forget to replace /a00/ with the url for your junction object.  When Save is clicked on the junction object, you will navigate back to the Record A.

 

Also, for info, you could do this by overriding the save button with a custom VF page but this would need to be a full VF replacement of the edit page layout and would be overkill for this requirement.

 

Thanks,

James.

All Answers

jayjaysjayjays

Hi,

 

you can do this by creating a custom button (List Button) on the junction object to replace the standard 'New' button.  The trick is to pass the saveURL parameter in the url with the id of the current record id  (Record A in your case).

 

For example, If your Record A was of a Custom Object named Test__c then the url for the button would look something like;

 

/a00/e?retURL=%2F{!Test__c.id}&saveURL=%2F{!Test__c.id}

 

Don't forget to replace /a00/ with the url for your junction object.  When Save is clicked on the junction object, you will navigate back to the Record A.

 

Also, for info, you could do this by overriding the save button with a custom VF page but this would need to be a full VF replacement of the edit page layout and would be overkill for this requirement.

 

Thanks,

James.

This was selected as the best answer
SteveA101SteveA101

Thanks James.  I was hoping to accomplish this without the use of VF.  I'll give it a try and let you know.  Thanks for the response!!

 

sambasamba

Looks good. Thanks.

SteveA101SteveA101

So to give a bit more info...my url seems to be a lot larger than your example:

 

https://na15.salesforce.com/a0H/e?CF00Ni00000065RRA=test2&CF00Ni00000065RRA_lkid=a04i0000002y0xh&retURL=%2Fa04i0000002y0xh

 

This is where the user is on the junction object entry screen...with standard options to save, save & new, and cancel.

 

What shouod my new button URL look like?

 

Thanks so much!!!

jayjaysjayjays
Hi Steve,

The two extra parameters in the url fill the master-detail relationship on the junction object, so replace the values with Name and id fields of your 'Record A' object.

/a0H/e?CF00Ni00000065RRA={!Test__c.Name}&CF00Ni00000065RRA_lkid={!Test__c.id}&retURL=%2F{!Test__c.id}&saveURL=%2F{!Test__c.id}

Where Test__c is the api name of your record A. retURL is the url to navigate to if the user clicks cancel.

Cheers.
sandeep@Salesforcesandeep@Salesforce

As per my suggestion It is not possible to override Save button.

SteveA101SteveA101

James,

 

Worked like a charm!!  Thank you!!!