3

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

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}
</aura:component>

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.

Edit

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:

https://success.salesforce.com/ideaView?id=0873A0000003TXFQA2

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. – shukla yogesh Apr 12 '18 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 '18 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. – shukla yogesh Apr 12 '18 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 '18 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.