I am trying to retrive field information for user fields using following code.
But except for the Name field of User, it is throwing error for every other field.
Any idea why its not letting me access user fields using schema.

I went ahead and tried Apex route also but same result.

import { LightningElement, wire, track } from 'lwc';
import USER_ID from '@salesforce/user/Id'; 
import NAME_FIELD from '@salesforce/schema/User.Name';
import PHONE_FIELD from '@salesforce/schema/User.Phone';
import ROLE_FIELD from '@salesforce/schema/User.UserRole.Name'; 

export default class myComponent extends LightningElement {
    @track error ; 
    @track name;
    @track phone;
    @track role;
    @wire(getRecord, {
         recordId: USER_ID,
         fields: [NAME_FIELD]
    }) wireuser({
     }) {
         if (error) {
            this.error = error ; 
         } else if (data) {
             this.name = data.fields.Name.value;
             //this.phone = data.fields.Phone.value;             
             //this.role = data.fields.UserRole.value.fields.Name.value;

Error Details:

Invalid reference User.Phone of type sobjectField in file myComponent.js: Source

Addtional Details:
I am using following extension for editing the code. Salesforce LWC Editor

  • You should have included the code as text as well.
    – sfdcfox
    May 9, 2022 at 23:21
  • @sfdcfox update the question. May 9, 2022 at 23:27
  • Are you using this component within experience cloud or regular lightning experience? May 10, 2022 at 1:07
  • @MohithShrivastava regular lightning experience, I am using LWC chrome extension. Salesforce LWC Editor. May 10, 2022 at 1:08
  • You mean chrome extension or chrome browser? May 10, 2022 at 1:09

3 Answers 3


This is a known issue with the LWC Deployment with the tooling API of Salesforce. If the underlying tool in your case the chrome extension uses tooling API for LWC Bundle deployment causing the issue.

Currently only workaround for this is to switch to alternate tools like SFDX CLI or use Salesforce VSCode extension to deploy your LWC component as those use Metadata API than using the tooling API.


For getting around similar error in LWC Editor, select 'Standard Deployment?' checkbox on the bottom right corner of the editor.

  • This worked for me...thanks
    – dschueler
    Feb 28 at 10:47

In case if you're using Intellij Idea + Illuminated Cloud 2:

  • Configure Illuminated Cloud 2 (gear icon)
  • Configure Application
  • Validation and Deployment tab
  • uncheck "LWC" checkbox in "Prefer Tooling API" for section

enter image description here

You must log in to answer this question.

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