+ Start a Discussion
RichardC.ax220RichardC.ax220 

Need to open "New" detail object form, maintaining link to master object

I have an app with two objects in a master-detail relationship. The detail object has a related list on the master with a New button. Clicking that New button opens an edit page for the detail object, with the master link field showing the master record from where I clicked New. If a user fills in the form and clicks the Save button, s/he gets the page for the detail record s/he just entered.
 
I want to add a "New" button to the detail page so the user can create another detail record under the same master record. I added a custom button linked to URLFOR referring to the "New" detail object. Clicking the button opens an edit page for the detail object, but the link field to the master object is empty, like all the other fields. I want that field linked to the current master record. This is for users who should have clicked the "Save & New" button, but instead clicked "Save". I want this new button to work like "Save & New", creating a sibling detail record sharing the same parent master record.
 
Does anyone know how to do that?
MarkSilberMarkSilber

You probably have seen this -- so it may not be exactly what you are looking for. I typically have users returned to the parent record after they have created the child record by overriding the New button and putting it on the related list of the parent screen. Here's a sample from one of our New button overrides. The window properties are set to open in the existing window without sidebar or header.

When the user presses Save or Cancel, they are returned to the parent automatically. This keeps them from having to click the parent hyperlink on the child screen to back to where they started from.

a0Q/e?CF00N50000001caDM={!Account.Name}&CF00N50000001caDM_lkid={!Account.Id}&retURL=%2F{!Competitive_Threat__c.AccountId__c}&saveURL=%2F{!Account.Id}&cancelURL=%2F{!Account.Id}
 
As for the "New" button on the child record, what field are you using to pass the master record to the child screen? It should be available to you since you are on a record that is already linked to the master record.