Sunday, 14 October 2018

Get Record Type Id from lightning component in standard new action override (getting any url parameter)

Hi ,

Here we have requirement to get record type id from lightning component when standard "New" action is overrided.


To get selected RecordTypeId from the component we have to implement the lightning interface "lightning:isUrlAddressable" which will be useful to access parameter "RecordTypeId" from the top level.


Eg:

Ligthtning Component:
----------------------------

<aura:component implements="lightning:isUrlAddressable" description="c:helloTarget component">
    <aura:attribute name="firstname" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    Hello {!v.firstname}.
</aura:component>

JavascriptController:
-------------------------
({
    init: function(cmp, evt, helper) {
        var myPageRef = cmp.get("v.pageReference");
        var firstname = myPageRef.state.RecordTypeId;
        cmp.set("v.firstname", firstname);
    }
})



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



No comments:

Post a Comment

What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...