You need to sign in to do that
Don't have an account?
Marcelo da Silva Velame
Lightning Web Components and Salesforce Data - Handler Server Errors
hi i'm working on this activity on this track but i couldn't implement step 5 of the activity in Visual Studio Code
Step 5 talks to comment the code I made in the class and put the activity code, I put it but I can't deploy it to org, it gives an error.
the trailhead activity link:
https://trailhead.salesforce.com/pt-BR/content/learn/modules/lightning-web-components-and-salesforce-data/handle-server-errors
My code:
HTML
<template>
<lightning-card>
<template if:true={accounts.data}>
<lightning-datatable
key-field="Id"
data={accounts.data}
columns={columns}
>
<template if:true={errors}>
<p>{errors}</p>
</template>
</lightning-datatable>
</template>
</lightning-card>
</template>
=====================================================
JavaScript
import { LightningElement, wire } from 'lwc';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import REVENUE_FIELD from '@salesforce/schema/Account.AnnualRevenue';
import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';
import getAccounts from '@salesforce/apex/AccountController.getAccounts';
import { reduceErrors } from 'c/ldsUtils';
const COLUMNS = [
{ label: 'Account Name', fieldName: NAME_FIELD.fieldApiName, type: 'text' },
{ label: 'Annual Revenue', fieldName: REVENUE_FIELD.fieldApiName, type: 'currency' },
{ label: 'Industry', fieldName: INDUSTRY_FIELD.fieldApiName, type: 'text' }
];
export default class AccountList extends LightningElement {
columns = COLUMNS;
@wire(getAccounts)
accounts;
get errors() {
return (this.accounts.error) ?
reduceErrors(this.accounts.error) : [];
}
}
=====================================================
XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>48.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
=====================================================
APEX CLASS
public with sharing class AccountController {
@AuraEnabled(cacheable=true)
public static List<Account> getAccounts() {
/*return [
SELECT Name, AnnualRevenue, Industry
FROM Account
WITH SECURITY_ENFORCED
ORDER BY Name
];
*/
}
}
===========================================
After putting it as requested in the challenge do not deploy to org the error.
Am I doing something wrong in the code?
Step 5 talks to comment the code I made in the class and put the activity code, I put it but I can't deploy it to org, it gives an error.
the trailhead activity link:
https://trailhead.salesforce.com/pt-BR/content/learn/modules/lightning-web-components-and-salesforce-data/handle-server-errors
My code:
HTML
<template>
<lightning-card>
<template if:true={accounts.data}>
<lightning-datatable
key-field="Id"
data={accounts.data}
columns={columns}
>
<template if:true={errors}>
<p>{errors}</p>
</template>
</lightning-datatable>
</template>
</lightning-card>
</template>
=====================================================
JavaScript
import { LightningElement, wire } from 'lwc';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import REVENUE_FIELD from '@salesforce/schema/Account.AnnualRevenue';
import INDUSTRY_FIELD from '@salesforce/schema/Account.Industry';
import getAccounts from '@salesforce/apex/AccountController.getAccounts';
import { reduceErrors } from 'c/ldsUtils';
const COLUMNS = [
{ label: 'Account Name', fieldName: NAME_FIELD.fieldApiName, type: 'text' },
{ label: 'Annual Revenue', fieldName: REVENUE_FIELD.fieldApiName, type: 'currency' },
{ label: 'Industry', fieldName: INDUSTRY_FIELD.fieldApiName, type: 'text' }
];
export default class AccountList extends LightningElement {
columns = COLUMNS;
@wire(getAccounts)
accounts;
get errors() {
return (this.accounts.error) ?
reduceErrors(this.accounts.error) : [];
}
}
=====================================================
XML
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>48.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
</targets>
</LightningComponentBundle>
=====================================================
APEX CLASS
public with sharing class AccountController {
@AuraEnabled(cacheable=true)
public static List<Account> getAccounts() {
/*return [
SELECT Name, AnnualRevenue, Industry
FROM Account
WITH SECURITY_ENFORCED
ORDER BY Name
];
*/
}
}
===========================================
After putting it as requested in the challenge do not deploy to org the error.
Am I doing something wrong in the code?
For all the Certification and Trailhead Guidance please report it here,
https://trailhead.salesforce.com/en/help?support=home
https://trailhead.salesforce.com/help
So that our trailhead support engineers will look into it and get back to you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Regards,
Salesforce Support.