LWC - JS: Import custom field using @Salesforce/Schema does not compile
Version 2.1.9.2 - Build 20211014095816
IntelliJ 2021.2.1 -Ic-212-5080.55
Windows: 2021-10 Cumulative Update for .NET Framework 3.5 and 4.8 for Windows 10 Version 21H1 for x64 (KB5005539)
Deploying changes to org - Issue is LWC saving, when you try to import a custom field on a custom object it gives an error, when it should allow you to save.
Business impact is I have to use VS code to write LWC
import RANKING_FIELD from '@Salesforce/schema/Account_Ranking__c.Ranking__c';
Error:(1, 1) FIELD_INTEGRITY_EXCEPTION - Invalid reference Account_Ranking__c.Ranking__c of type sobjectField in file opportunityClone.js: Source
This compiles in VS Code
Log attached
Comments (7)
-
reporter -
repo owner Please disable Tooling API-based deployment of LWC as it has known issues that Salesforce does not currently have plans to resolve. Note that IC2 warns about these issues when that option is enabled:
The details are covered in
#1589. -
repo owner - changed status to duplicate
Duplicate of
#1589. -
reporter That worked, thanks. I have been using IC2 for almost 5 years. Did not notice the pop up, Might have been a setting I set years ago lol.
As always, thank you for your quick response and thank you for continuing work on IC2!
-
repo owner My pleasure. It's an option I've considered removing altogether for exactly this reason, but some users still find it useful and have asked that it remain. What I may do is react to this specific error and automatically re-deploy via the metadata API when it happens, or perhaps even look at the content to be deployed and, if I know that it would trigger the error, do the same. That way for LWC bundle files that can use the tooling API, there's a speed benefit, and for those that can't, it won't be so disruptive.
-
reporter I like that idea!
Thank you for the details.
-
repo owner I actually committed that change about 15 minutes ago. You can see more details in
#1589. - Log in to comment
Also just updated IntelliJ and Kotlin to the latest version, still has the issue.