Posts

Showing posts with the label LWC

Lightning Record Picker Component in Salesforce

Image
The lightning-record-picker is a Salesforce Lightning Web Component that allows users to search and select a record from a specified object. It provides a user-friendly interface for selecting records and can be used in various contexts within Salesforce Lightning Experience. The lightning-record-picker component can be used in a Salesforce application to allow users on desktop or mobile devices to quickly find and select Salesforce records. The component's behavior and presentation can be configured, and filtering can enable users to retrieve and display records that meet specific criteria. This feature is generally available and includes changes since the last release. Previously, the component allowed for a maximum of 50 records, but now you can retrieve up to 100. Additionally, the component displays clear error messages when configuring invalid specifications and supports new attributes. To enable offline use, this component uses the GraphQL wire adapter. Below is an imaginar...

GraphQL API for Lightning Web Components

Image
GraphQL is a query language used to interact with APIs and a runtime that executes queries on existing data. Facebook developed this language in 2012 and released it as an open-source project in 2015. Unlike traditional RESTful APIs, GraphQL offers a more efficient, powerful, and flexible way to interact with APIs. Learn more about GraphQL at graphql.org  and GraphQL Architecture Here's a breakdown of what GraphQL is and its key features: Query Language : GraphQL allows clients to request the data they need from an API. Clients can specify the fields and relationships to retrieve, eliminating over-fetching and under-fetching data. Hierarchical Structure : GraphQL queries have a hierarchical structure similar to the shape of the data they retrieve. This allows clients to request nested data in a single query, reducing the number of round-trips to the server. Strongly Typed Schema : GraphQL APIs are built on top of a strongly typed schema that defines the types of data available and...

Salesforce Guide to Building Forms

Image
Salesforce Architects | Building Forms Guide Overview Looking to build forms on the Salesforce Platform? You’ve got multiple options, spanning the entire low-code to pro-code continuum. Representing low-code, Dynamic Forms in Lightning App Builder and screen flows in Flow Builder. Hanging out in the middle of the continuum is the ability to extend screen flows with LWCs. And representing pro-code is the LWC framework and its ever-growing library of base components. Options are great, but how do you determine which one (or which combination) is the right option? That’s where this doc comes in. Takeaway #1: When building basic create/edit forms for custom objects on desktop Lightning Pages, use Dynamic Forms. Takeaway #2: Use Flow to build multi-screen forms. If you need to also meet precise UX requirements, layer in LWCs. Takeaway #3: If you need test automation, start with LWC. You can write unit tests for any LWC, regardless of where you plan to embed it.

Salesforce custom label in Apex, Visualforce, AURA, LWC

Salesforce custom labels can be used across different Salesforce technologies, including Apex, Visualforce, Aura components, and Lightning Web Components (LWC). Here's how you can use custom labels in each of these contexts: Apex : In Apex, you can access custom labels using the System.Label global variable. Custom labels are referenced by their developer name. String labelValue = System.Label.MyCustomLabel; Visualforce : In Visualforce pages, you can reference custom labels using the $Label global variable. <apex:outputText value="{!$Label.MyCustomLabel}" /> Aura Components: In Aura components, you can access custom labels using the $Label global value provider. <aura:component>     <aura:attribute name="labelValue" type="String" default="{!$Label.MyCustomLabel}" /> </aura:component> Lightning Web Components (LWC): In Lightning Web Components, you can import and reference custom labels using the @salesforce/label scop...

Lightning Components Performance Best Practices

Optimizing the performance of Lightning components is crucial for delivering fast and responsive user experiences in Salesforce applications.  Here are some best practices to improve the performance of Lightning components: Use minified versions of libraries and style sheets Use a content delivery network (CDN) Enable browser caching Use smaller image files CDN and Browser Caching wherever possible is a given.  Cloudflare CDN was used. Akamai is another common option. this is a must-have Custom Fonts (TTF files) were used from Google in the site implementation which was surprisingly taking a long time for browsers to download and use. So we moved to standard fonts which increased the score significantly. If you absolutely need to use Custom Fonts, then there are options in the community to preload this custom font as a static resource which loads faster compared to the Google Reference\ The CSS file was heavily optimized and instead of using images, we used CSS styles for some...

Dynamically Calling JavaScript Functions

Dynamically invoking JavaScript functions enhances code flexibility and efficiency. By dynamically calling JavaScript functions, we can create more flexible and efficient applications that adapt to various scenarios. Dynamic Functionality : Dynamically calling JavaScript functions allows your code to adapt to different scenarios and conditions at runtime. This flexibility lets you execute functions based on user interactions, system events, or data-driven logic. Code Reusability : By dynamically invoking JavaScript functions, you can reuse standard functions across multiple components or modules within your application. This promotes code modularity, reduces duplication, and leads to cleaner and more maintainable code. Conditional Logic: Dynamically invoking functions allows you to apply conditional logic to determine which functions to execute based on specific conditions or criteria. This enables you to build more intelligent and adaptive applications that respond dynamically to cha...