Handle Server Errors | Lightning Web Components and Salesforce Data | Salesforce Trailhead

preview_player
Показать описание
Module: Lightning Web Components and Salesforce Data
Develop Lightning web components that interact with data in your Salesforce org.
Unit-3: Handle Server Errors
#salesforce #trailhead #codding
Solution of Salesforce Trailhead - Handle Server Errors

Your Queries

salesforce
salesforce developer
salesforce crm
salesforce cpq
salesforce intergation
salesforce marketing cloud
salesforce administration job
salesforce trailhead

trailhead playground management
trailhead salesforce
trailhead
trailhead and trailblazer community
trailhead navigation quick look
trailhead quick look
trailhead salesforce developer beginner
trailhead playground management install apps and packages in your trailhead playground
trailhead playground management create a trailhead playground
trailhead admin beginner answer
trailhead salesforce modules answer
trailhead salesforce in telugu
trailhead for companies
trailhead account creation

Welcome to our YouTube channel dedicated to Salesforce Trailhead tutorials and tips! Join our growing community of aspiring Salesforce professionals by subscribing now. By subscribing, you'll receive regular doses of motivation and expert guidance to conquer every Salesforce challenge you encounter.

Remember, the above description is just a suggestion. Feel free to customize it according to your channel's unique style and content. Good luck with your Salesforce Trailhead tutorials, and may your channel inspire and empower learners on their Salesforce learning journeys!

Whether you're new to Salesforce or an experienced user looking to enhance your skills, our tutorials are designed to be engaging, informative, and practical. We cover a wide range of topics, including Salesforce administration, development, customization, integration, and much more. Each video is carefully crafted to help you gain a deeper understanding of Salesforce concepts and successfully navigate the Trailhead learning platform.

Our dedicated instructors are passionate about Salesforce and have extensive experience in the industry. They'll provide you with step-by-step guidance, best practices, and insider tips to ensure your Salesforce journey is a success. We understand that learning can sometimes be challenging, but with our tutorials, you'll have the motivation and support you need to overcome any obstacle.

We also value your input and suggestions! If there are specific topics or challenges you'd like us to cover in our tutorials, please leave a comment below or connect with us on our social media platforms. Your feedback helps us create content that meets your needs and ensures you get the most out of your Salesforce learning journey.

By subscribing to our channel, you'll gain access to a growing library of high-quality Salesforce Trailhead tutorials. We'll guide you through various modules, projects, and superbadges, equipping you with the knowledge and skills necessary to succeed in the Salesforce ecosystem.

So, what are you waiting for? Hit the subscribe button now and become a part of our supportive community of Salesforce learners. Don't forget to click the notification bell so you never miss a new tutorial or Trailhead challenge!

Thank you for choosing our channel as your Salesforce learning companion. Let's embark on this exciting journey together, empower ourselves with Salesforce skills, and unlock limitless career opportunities. Good luck, and let's dive into the world of Salesforce Trailhead!
Рекомендации по теме
Комментарии
Автор

LWC Code :

IdsUtils.js:-


/**
* Reduces one or more LDS errors into a string[] of error messages.
* @param errors
* @return {String[]} Error messages
*/
export function reduceErrors(errors) {
if (!Array.isArray(errors)) {
errors = [errors];
}

return (
errors
// Remove null/undefined items
.filter((error) => !!error)
// Extract an error message
.map((error) => {
// UI API read errors
if (Array.isArray(error.body)) {
return error.body.map((e) => e.message);
}
// UI API DML, Apex and network errors
else if (error.body && typeof error.body.message === 'string') {
return error.body.message;
}
// JS errors
else if (typeof error.message === 'string') {
return error.message;
}
// Unknown error shape so try HTTP status text
return error.statusText;
})
// Flatten
.reduce((prev, curr) => prev.concat(curr), [])
// Remove empty strings
.filter((message) => !!message)
);
}



IdsUtils.js-meta.xml:-

<?xml version="1.0" encoding="UTF-8"?>

<isExposed>false</isExposed>
</LightningComponentBundle>



contactList.html:-

<template>
<lightning-card>
<template if:true={contacts.data}>
<lightning-datatable key-field="Id" data={contacts.data} columns={columns}> </lightning-datatable>
</template>
<template if:true={errors}>
<p>{errors}</p>
</template>
</lightning-card>
</template>


contactList.js:-


import { LightningElement, wire } from "lwc";
import { reduceErrors } from "c/ldsUtils";

const COLUMNS = [
{
label: "First Name",
fieldName: FIRST_NAME_FIELD.fieldApiName,
type: "text"
},
{
label: "Last Name",
fieldName: LAST_NAME_FIELD.fieldApiName,
type: "text"
},
{ label: "Email", fieldName: EMAIL_FIELD.fieldApiName, type: "email" }
];

export default class ContactList extends LightningElement {
columns = COLUMNS;
@wire(getContacts)
contacts;

get errors() {
return this.accounts.error ? : [];
}
}


ContactColtroller.cls:-

public with sharing class ContactController {
@AuraEnabled(cacheable=true)
public static List<Contact> getContacts() {
// The following line is used only for the last challenge
throw new AuraHandledException('Forced error');
// return [SELECT FirstName, LastName, Email FROM Contact WITH SECURITY_ENFORCED ORDER BY LastName, FirstName];
}
}

TrailheadTitans