Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect validation on LWC Meta XML for lightning__RecordPage targeted objects #3503

Open
greg-amato opened this issue Aug 15, 2021 · 3 comments

Comments

@greg-amato
Copy link

greg-amato commented Aug 15, 2021

Summary

When determining the configuration for a LWC that targets a record page "lightning_RecordPage", you can restrict the target objects by specifying tag, followed by the allowable objects.

However, the VSCode extension is incorrectly flagging <objects> as an invalid element name. Note: The code will still deploy correctly.

See reference documentation here

"The targetConfig tag supports the property, propertyType, objects, and supportedFormFactors subtags."

objects
Limits the component to a set of one or more objects. If you don’t use this tag set, the component supports all supported objects. This tag set works only inside a parent targetConfig that’s configured for lightning__RecordPage.
Specify the objects tag set only one time inside a targetConfig set. Supports the object subtag.

object
Defines which objects the component is supported for. Use one object tag for each supported object.
See the User Interface API Developer Guide for the list of supported objects.

Steps To Reproduce:

  1. Create an new LWC with manifest in VS Code with lightning extensions installed
  2. Update LWC meta file to target a record page and restrict to object(s)
  3. Add example code like below
<targets>
    <target>lightning__RecordPage</target>
</targets>
<targetConfigs>
     <targetConfig targets="lightning__RecordPage">
            <property label="Title" name="cmpTitle" type="String"/>
            <objects>
                <object>Case</object>
                <object>Account</object>
            </objects>
      </targetConfig>
</targetConfigs>

Expected result

No code validation flagged for error.

Actual result

Invalid element name:
 - objects

One of the following is expected:
 - property
 - propertyType
 - supportedFormFactors

Error indicated by:
 {http://soap.sforce.com/2006/04/metadata}
with code:xml(cvc-complex-type.2.4.a)
Limits the component to a set of one or more objects. If you don’t use this tag set, the component supports all supported objects. This tag set works only inside a parent

Additional information

Screenshot of error
Screen Shot 2021-08-15 at 11 25 37 AM

Screenshot of example config that should validate correctly
Screen Shot 2021-08-15 at 11 25 12 AM

Salesforce Extension Version in VS Code: 52.9.1

SFDX CLI Version: sfdx-cli/7.112.1 darwin-x64 node-v14.17.4

OS and version: MacOS 11.5.1

@uip-robot-zz
Copy link

This issue has been linked to a new work item: W-9762407

@tcampb
Copy link

tcampb commented Sep 14, 2021

@greg-amato - it looks like the error is due to the objects tag being declared after the property tag. When I moved the objects tag above the property tag the error was resolved.

I'm not sure if this was intended, but according to the js-meta.xsd file (see below) the objects tag must come first since the parent element is a sequence element.

The sequence element specifies that the child elements must appear in a sequence.

<xs:sequence>
<xs:element type="xs:boolean" name="hasStep" minOccurs="0">
<xs:annotation>
<xs:documentation>Specify that your component requires an attached step to function as expected. Only valid for `analytics__Dashboard` targets. When set to `true`, the Tableau CRM dashboard builder UI prompts you to attach an existing step or create a new step when creating an instance of your component. Components with an attached step have access to step-specific properties like `results` and `selection`.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="objects" name="objects" minOccurs="0" />
<!-- Do allow these unbounded ones to be unordered, which makes the propertyType example in the docs validate -->
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="property" name="property" />
<xs:element type="propertyType" name="propertyType" />
</xs:choice>

image

@trinasfdx trinasfdx assigned mohanraj-r and jeffb-sfdc and unassigned mohanraj-r Mar 23, 2022
@trinasfdx trinasfdx added the status:in review pr/issue is being reviewed label Apr 1, 2022
@jeffb-sfdc
Copy link
Contributor

jeffb-sfdc commented Apr 1, 2022

forcedotcom/lightning-language-server#446 is a duplicate of this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants