0

We are building manage package with quick action using lwc component,

Some customers need to trigger API and some doesn't.

So we decided to keep a Boolean check in the target config.

I am getting following error

The 'property' tag isn't supported for lightning__RecordAction

My config file:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>58.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordAction</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
            <actionType>ScreenAction</actionType>
            <property name="isTriggerAPI"
                      type="Boolean"
                      label="Trigger API"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

What is the best approach to over come this issue, other than creating two container component with default values ?

3
  • Note: Already customers are using this component and isExposed is set to be true, Not sure if I turn it to false will allow me to build new manage package ? or it will accept package upgrade in customer orgs ?
    – Ragul
    Commented Sep 23, 2023 at 13:07
  • Add a custom setting or custom metadata type that the LWC reads to find out how to behave?
    – Phil W
    Commented Sep 23, 2023 at 14:24
  • 1
    Yes I thought the same, But we do have multiple objects mostly customers will create quick action by selecting component.
    – Ragul
    Commented Sep 23, 2023 at 15:43

1 Answer 1

0

The error that you are getting is because the property tag is not supported for the lightning__RecordAction target. According to the documentation, the property tag is only supported for the following targets:

  • lightningCommunity__Default
  • lightningCommunity__Page
  • lightningCommunity__Page_Layout
  • lightningCommunity__Theme_Layout
  • lightningSnapin__ChatHeader
  • lightningSnapin__ChatMessage
  • lightningSnapin__Minimized
  • lightningSnapin__PreChat

Therefore, you cannot use the property tag to expose a Boolean check in the target config for the lightning__RecordAction target.

One possible way to overcome this issue, other than creating two container components with default values, is to use a custom metadata type to store the Boolean value for each customer. You can create a custom metadata type with a Boolean field and a lookup field to the User object, and then populate the records with the values for each customer.

For example, you can create a custom metadata type named Trigger_API_Setting__mdt with the following fields:

  • User__c: a lookup field to the User object
  • Is_Trigger_API__c: a Boolean field to store the value of the Boolean check

Then, you can create records for each customer with their user ID and the Boolean value.

In your LWC component, you can use Apex to query the custom metadata type and get the Boolean value for the current user. For example, you can use the following code to get the Boolean value:

Apex class

public with sharing class TriggerAPIService {
        // Method to get the Boolean value from the custom metadata type
        @AuraEnabled(cacheable=true)
        public static Boolean getIsTriggerAPI() {
                Id userId = UserInfo.getUserId();
                Trigger_API_Setting__mdt setting = [SELECT Is_Trigger_API__c
                                                    FROM Trigger_API_Setting__mdt
                                                    WHERE User__c = :userId];
                return setting.Is_Trigger_API__c;
        }
}

LWC component

import { LightningElement, wire } from 'lwc';
import getIsTriggerAPI from '@salesforce/apex/TriggerAPIService.getIsTriggerAPI';

export default class TriggerAPIComponent extends LightningElement {

        @wire(getIsTriggerAPI)
        isTriggerAPI;
       
        triggerAPI() {
                if (this.isTriggerAPI.data) {
                        // Trigger the API
                } else {
                        // Do not trigger the API
                }
        }
}

This way, you can use a custom metadata type to store and retrieve the Boolean value for each customer, without using the property tag in the target config.

1
  • Thanks for your time, answering my question. Yes currently no other options other than duplicating lwc.
    – Ragul
    Commented Jan 3 at 12:54

You must log in to answer this question.

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