7

I am developing a ISV solution, which includes a LWC component, that can be used in all record pages.

To achive this, i made this metadata:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>45.0</apiVersion>
    <description>abc</description>
    <isExposed>true</isExposed>
    <masterLabel>abc</masterLabel>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <objects>
                <object>Account</object>
            </objects>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

As you can see, this component can be used on the Account record page now. But as i stated before, we are ISV and we want to enable admins to use this component on all kinds of objects, including custom objects which we don't know on beforehand.

One of the solutions i thought of is wrapping the LWC component in a Aura component, where you can expose a component to all possible custom/standard object record pages. In Aura it's sufficient to include the (implements="flexipage:availableForRecordHome"):

<aura:component implements="flexipage:availableForRecordHome"
                access="global">

    <!-- This is the LWC component: -->
    <c:abc /> 


</aura:component>


.

But what if you want a native LWC component, is there a way to achive this?

9

In this case, targetConfigs is an optional tag. it is upon you, weather you want to restrict the component to be used on some particular object record page. If you don't want, simply remove the below part of the code:-

    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <objects>
                <object>Account</object>
            </objects>
        </targetConfig>
    </targetConfigs>

and just use:-

    <targets>
        <target>lightning__RecordPage</target>
    </targets>

Note:-

targets:- Specifies where the component can be added, such as on a type of Lightning Page or in Embedded Service Chat. If you want your component to appear in the Lightning App Builder or in Community Builder, specify at least one Lightning page type.

target:- A Lightning page type. Valid values are:

targetConfigs:- Configure the component for different page types and define component properties. For example, a component could have different properties on a record home page than on the Salesforce Home page or on an app page.

Read more here:- Configuration File Tags

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.