0
0

More than 1 year has passed since last update.

Visualforce から Lightning Web コンポーネントへの移行 > Lightning Web Components for Visualforce Developers > Handle User Actions in JavaScript

Last updated at Posted at 2022-01-25
  • プレイグランドの名前? lwc_for_vf_devs

エラーメッセージ

  • We can't find a component named 'accountFinder' on the LWC Visualforce Devs page. Make sure you successfully deployed the component files to your Trailhead Playground, and add the component to the page.

ハンズオンの Challengeを実行する前

  • We can't find the 'annualRevenue' property initialized to 'null' in the accountFinder JavaScript. ああ、間違えている。
import { LightningElement } from 'lwc';
export default class AccountSearch extends LightningElement {
    numberOfEmployees = null;
    handleChange(event) {
        this.annualRevenue = event.detail.value;
    }
    reset() {
        this.annualRevenue = null;
    }
}

最終形

<template>
    <lightning-card>
        <lightning-input
            type="number"
            label="Annual Revenue"
            value={annualRevenue}
            formatter="currency"
            onchange={handleChange}>
        </lightning-input>
        <lightning-button
            label="Reset"
            onclick={reset}>
        </lightning-button>
    </lightning-card>
  </template>
import { LightningElement } from 'lwc';
export default class AccountSearch extends LightningElement {
    annualRevenue = null;
    handleChange(event) {
        this.annualRevenue = event.detail.value;
    }
    reset() {
        this.annualRevenue = null;
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
    </targets>
</LightningComponentBundle>

Work with Salesforce Data

  • LWC1503: Parsing error: /home/sfdc/tools/lwc/2.2.9-234.6/accountSearch.js: Leading decorators must be attached to a class declaration. (11:8) (11:8)

よく分からん。Apex Classの名前を間違えていた?

import { LightningElement, wire } from 'lwc';
import queryAccountsByEmployeeNumber from '@salesforce/apex/AccountListControllerLwc.queryAccountsByEmployeeNumber';
export default class AccountSearch extends LightningElement {
    numberOfEmployees = null;
    handleChange(event) {
        this.numberOfEmployees = event.detail.value;
    }
    reset() {
        this.numberOfEmployees = null;
    }
@wire(queryAccountsByEmployeeNumber, { numberOfEmployees: '$numberOfEmployees' })
accounts;
}
  • We can't find a method named 'queryAccountsByRevenue' in the AccountListControllerLwc class.

  • Unable to find Apex action method referenced as 'AccountListControllerLwc.queryAccountsByRevenue'.

何だ?意味が分からん。何度も保存、デプロイを繰り返したらエラーが消えた。分からんなぁ。

  • We can't find an Apex class named 'AccountListControllerLwc'.

Apexクラスを作った時にコピペの範囲が足らないまま名前をつけたので、renameしたのが悪かったのか?
しかし、プレグランドでは正常な名前になっている。何見てんだろうねぇ。
いつものようにチェックロジックは理解できん。

シークレットモードも効かないので、仕方なく別の環境にデプロイします。

  • We can't find an 'annualRevenue' parameter of type 'Decimal' in the queryAccountsByRevenue method.

はいはい、Apexだけ新しい環境にしてもダメ?

コンポーネントもデプロイしたけど、同じエラー。

ああ。変数の宣言間違えた。

最終形

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0