Errors in VS Code for the Salesforce Work with Salesforce Data Unit

  Uncategorised

I have re-read the section and tried to figure out the solution via youtube and playing around with the code. I am sure the answer is obvious but I am not sure exactly what the errors mean (I am not well versed in error language).

Here is the code:

public with sharing class AccountListControllerLwc {
@AuraEnabled(cacheable=true)
public static List<Account> queryAccountsByEmployeeNumber(Integer numberOfEmployees) {
    return [
        SELECT Name
        FROM Account
        WHERE NumberOfEmployees >= :numberOfEmployees
    ];

}

@AuraEnabled(cacheable=true)
public static List<Account> queryAccountsByRevenue(Decimal annualRevenue) {
    return [
        SELECT Name
        FROM Account
        WHERE AccountRevenue >= :annualRevenue
    ];

}
}

The error is seen in public static List queryAccountsByRevenue(Decimal annualRevenue) {
return [
Specifically about return [ with the following error message:

WHERE AccountRevenue >= :annualRevenue
^
ERROR at Row:4:Column:19
No such column ‘AccountRevenue’ on entity ‘Account’. If you are attempting to use a custom field, be sure to append the ‘__c’

This is an apex class file.

This is the second bit of code and is an apex class .XML file.

<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <status>Active</status>
</ApexClass>

The error for this states:
cvc-elt.1.a: Cannot find the declaration of element ‘ApexClass’.

I didn’t have this error before, I am not sure what I did the Apex class to receive it. I copied all the necessary code from Salesforce units, so I am not sure what the issue is.

The third error I have is based on this bit of code:

    import { LightningElement, wire } from 'lwc';
import queryAccountsByRevenue from '@salesforce/apex/AccountListControllerLwc.queryAccountsByRevenue,';
export default class AccountFinder extends LightningElement {
    annualRevenue = null;
    handleChange(event) {
        this.annualRevenue = event.detail.value;
    }
    reset() {
        this.annualRevenue = null;
    }
    @wire(queryAccountsByRevenue, { annualRevenue: '$annualRevenue' })
accounts;
}

The error is:

LWC1500: Invalid module id "@salesforce/apex/AccountListControllerLwc.queryAccountsByRevenue,". (2:35)

from this line of code:

import queryAccountsByRevenue from '@salesforce/apex/AccountListControllerLwc.queryAccountsByRevenue,';

this is a .js file.

What do the errors mean and how do I fix them?

Source: Visual Studio Questions

LEAVE A COMMENT