1

Scenario:

A Lightning component that is being used as:

-a quick action override of the "New" button of CustomObject1 and

-as a quick action override of the "New" button of CustomObject1 in the related list of Account

How can i differentiate the caller origin. Because if the lightning component is called from the Account related list i want the account field automatically filled. If the lightning component is called from the CustomObject1 New button then the field should be manually selected

3 Answers 3

2

This cannot be done in a simple way - you can see my question Lightning component quick action - send parameters to the lightning component and it's answers

What I did eventually was - creating a main component with all the functionality and for each button creating a wrapper component that sends a parameter to differentiate between the 2 buttons

1

You can implement force:hasSObjectName interface in your lightning component and you can get the name of the sObject type.

<aura:component implements="force:hasSObjectName">
<aura:attribute name="sobjecttype" type="String" default="{!v.sObjectName}"/>
</aura:component>

The sobjecttype attribute holds the value you need.

4
  • Thanks for the reply - clicking the new button on the related list customObject1 on the Account record - gives me the 'CustomObject1' value in the sobjecttype attribute - whereas i want to have 'Account'
    – owsata
    Commented Jun 13, 2018 at 12:10
  • Aah, did you implement force:hasRecordId? what Id is this recordId attribute holding. Commented Jun 13, 2018 at 12:13
  • component.get("v.recordId"); gives me undefined in both cases - have implemented the force:hasRecordId interface
    – owsata
    Commented Jun 13, 2018 at 12:44
  • I guess I will have to leave it to rest of the community then! Commented Jun 13, 2018 at 19:31
1

From what I understand clicking the new button on the related list customObject1 on the Account record - gives you the 'CustomObject1' value in the sObjectType attribute - whereas you want to have 'Account'.

For this: You can use "Is Url Addressable" Component to get parent record (Account) details information like Id as you are on detail page of account. And anyways related list (CustomObject1) context you are receiving on clicking New via Related List.

https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation

You must log in to answer this question.

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