Is there any way to override 'New' standard button with lightning component and refer the parent record as prepopulated value in record creation screen?

I saw in some posts to achieve this using visualforce override and pass parent recordid in url but I wanted to achieve using only lightning component.

Please let me know if more details are needed.

Screenshot and highlighted standard action

As shown in screenshot I have to override this standard 'New' action to open a form and prepoulated opportunity and account information and few fields of Agreement record itself.

2 Answers 2


You haven't described what you're actually trying to achieve in the question (please do add that to your question), so I'm not sure if my first suggestion will be enough, but I have two suggestions...

The first thing I'd do is see if you can achieve your aim using a Quick Action instead of writing a component. If you can, then that saves you having to write/maintain code and that's great.

If that doesn't work, suggestion number two is to write a custom component Write it like this:

<aura:component description="NewObjectAction" implements="force:LightningQuickAction,force:hasRecordId">
    Parent record is {!v.recordId}

Set that up as a Lightning Component type of action on the parent object and it will receive the recordId of the parent record when pressed.


Two ideas weren't enough! After the question was updated, the actual requirement was to have custom actions appear in the standard related list in LEX. Which is not possible (yet) vote on the idea here:


So the only options are to put this functionality on the main record's actions in the top-right of the UI, or to write your own related-list.

  • Hi Aidan Thanks for responding. I have added few more details in question. Please can you check now. I have to replace or add a new button in related list view. Apr 12, 2018 at 14:33
  • If you want to override that New button on a standard related-list object, then I believe you're stuck for now (see success.salesforce.com/ideaView?id=0873A0000003TXFQA2). So you can either add a button to the record itself (top-right of the whole screen) or roll your own related list component
    – Aidan
    Apr 12, 2018 at 15:19
  • Thanks Aidan. What you would suggest as a better approach- Having a related list component or Try to have visualforce override? Having a parent level action also doesn't seem a bad idea until we have a lot of such actions to look opportunity page overpopulated. Apr 12, 2018 at 15:49
  • I wrote my own related-list component. Otherwise, you have to tell your users not to use the button on the related list, but to use a different one instead. Which is confusing for them. And if you write your own related-list, then you can write in other neat features like being able to filter which records are shown. It's quite a lot of effort to do well, though. I guess the other option is wait until SF allow you to do what you want. I've not seen it on a roadmap, but it's obviously required at some point
    – Aidan
    Apr 13, 2018 at 8:13

Adding my late 2019/ early 2020 experience to thread for others that land here from searching...

'CF' page parameters and the '_lkid':

Project for client required solution for a related list (--child junction object). So requirement is override New action on related list. Right now using VF page with a controller.

Solution works by assigning APEXPAGE.currentpage.getparameters() to a map and looping through keyset() of this map looking for the 'CFxxxxxxx_lkid' pattern. The _lkid parameter value is the recordid of the junction object relationship --essentially the parentId of the relation to the child (of the related List). This parameter populates the saveURL parameter. The xxxxxx value will vary based on Org and relationships but it is the id of the relationship name. Here is how this _lkid parameter looks in my project: CF00N0r0000016cCV_lkid.

For ORG 'safety', instead of hardcoding the CF parameter using ApexPages.currentPage().getParameters().get('CF00N0r0000016cCV_lkid'), I assign page parameters to a map: Map<String, String> urlParams = ApexPages.CurrentPage().getParameters(); then I for (String key: urlParams) loop through the map key looking for key.endsWithIgnoreCase('_lkid') pattern. When found assign the value to controller variable for object record.

In my controller, related custom object is docObj and target related field is part__c will have the parentId, so docObj.part__c = urlParams.get(key). After Save operation, new related record will have its Record Id and part__c with correct value to make the relation to parent --from the _lkid.

CAUTION is to assign APEXPAGE.currentpage.getparameters() to map variable in Controller Constructor early to store all of them. I experienced the 'BlackBox' nature of SF ops, the parameters values seem to be volatile and go 'dark' (null) if too much happens in controller before inspecting them.

Another 'dang' moment is after Save, retURL takes you back to detail record but related list is not refreshed. You have to force refresh of detail page in the save operation return with PageRefrence redirect=true.

New related list record (VF v. LEX):

I override the custom object's new action with a VF page (object's setup Buttons, Links, Actions). I designed the VF page to be 'popover modal' styled to mimic SF UX but Salesforce pushes the VF page into a different domain and uses an iframe so the parent detail page falls out of view and replaced by iframe empty background. VF page's APEX:Form is positioned in middle with CSS. It sort-of feels like SF UX but still makes you go 'dang SF, really?' because VF is in iframe 'jail'. The Cancel button for NEW action in VF page uses the page parameter retURL. LEX: I would prefer to use Lightning form vs VF page but querying the page 'CF' parameters in javascript controller's init is not as mature as APEX controller. Still working on the LEX controller.

Hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .