+ Start a Discussion
cinov8cinov8 

Pass parent object paramemeter via related list "New" button

I am trying to override the "New" layout for a related list object.  The flow is this:

 

1) User navigates to the related list and clicks "New Object".

2) They should be presented with all the fields on the detail page.

3) When they click Save, I want them to be redirected back to the parent record, not the details for the new related list object. It's like creating a new Contact off an Account, then being redirected to the Account after save as opposed to the Contact details.

 

How do I pass the parent record Id in via the related list object using Visualforce, or is there an easier way to do this?

HarmpieHarmpie
Create a new custom list button on the (related) object, and put it on the page layout of the master object. Button code should be of type URL and look sometihng like this: /apex/mypage?parentobjectid={!ParentObject.Id}. In the controller for your Visual force page, make sure the save action returns the master objects view() pagereference.
Paul DevenportPaul Devenport
{!URLFOR("/apex/PD_CustomAttachment?id="+ !ParentObject.Id)}  gives me syntax error when saving...
I am looking for a literal keyword like ParentObject that refers to any parent and is not tied to a hardcoded type like:  Contact.Id
Any ideas?  Does this even exist in visualforce/apex?