3

How can I make some properties in the meta file mandatory?

I have defined a few properties in below format

<targetConfigs>
  <targetConfig targets="lightning__RecordPage">
    <property name="somenumber" label="Some Number" type="Integer" default="0" />
  </targetConfig>
</targetConfigs>

Although I have given a default value, but it will be a problem if some admin will delete the default value. (I have to make this property configurable for admins). So, how to make the property mandatory?

I'm trying to find something similar to "Required Attributes" feature mentioned here.

Note:- Most of my properties are either String (with free text and not with apex data source) or Integer

1 Answer 1

5

Unless I'm missing something with your question, why can't you just add the required attribute to your property?

e.g.

<targetConfigs>
  <targetConfig targets="lightning__RecordPage">
    <property name="somenumber" label="Some Number" type="Integer" default="0" required="true" />
  </targetConfig>
</targetConfigs>

For more info: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_configuration_tags

2

You must log in to answer this question.

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