Posts

Showing posts from 2019

Reusable Form Using Custom Metadata and Design Attribute in LWC

Image
This post will explain how to use custom meta data and design attribute to create a reusable form component using lightning-record-form tag. Below are the steps you can follow to create reusable form. Step 1: Create Custom Meta Data Type (Form Fields) and one custom field(Field APIs) which is of data type Long Text Area on the custom meta data. Step 2: Create Record is custom meta data as defined in below screenshot. I have created two record one is for Account object and another is for Contact object and i have added the field API in a comma separated text on the Field APIs field. Make Sure the Label and Developer name on the records should be the object API. Step 3: Create the Lightning Web Component. In LWC we will use @api decorator to make the property public and this property will be added in meta.xml file to be available as a design attribute while dragging the component on home page. After dragging the component on home page we will set the object API and

Send LWC as PDF attachment in an Email

Use Case : We have an requirement where we need to send chart rendered on LWC component as PDF attachment in an email. Solution: We have external libraries available which can help to build the above use case. Prerequisite: Download below static resource file from below. 1. Jquery.min.Js 2. JSPdf.js 3.  html2canvas.min.js 4.  rgbcolor.js 5. Canvg,js This post is an enhancement on my previous blog to send LWC component as a PDF attachment. Creating the component displayChart.html <template> <div class="chart" lwc:dom="manual"></div> <div class = 'slds-box slds-theme_default printPdf' > <!-- content to be printed inside the pdf included in div--> <canvas class="pie-chart" width="800" height="450" lwc:dom="manual"></canvas> </div> <div class="slds-box slds-theme_default"> <lightning-button labe

Draw Chart in LWC using chart.js

Image
Leverage The art of Chart in our very own LWC R eports are the soul of any business. Though Salesforce provides the power of customizable reports, it comes with limited filtering options. To solve this limitation and spice up our visuals, we have something called “ ChartJS”. For any complex business reports, this shall act has a medium of simplicity, providing visual extravaganza. By using ChartJs , we can make sure that reports can be visualized much easier, also adding exponential power filters. This intern will make your business float on Cloud Nine. All these can be done in the new booming phrase “LWC”. Please find the steps below to achieve ChartJs in LWC. First Things First:                             ·    Download ChartJs from here .               ·       Create the Lightning Web Component. displayChart.html <template> <div class="chart" lwc:dom="manual"></div> <div class='slds-box s

Find duplicate records

This post will help you find the duplicate record Id in apex before creating a record in salesforce. Standard salesforce feature will always warn you about the duplicate record error, when you try to create a contact, lead and account using the standard way. What if you want to check for the duplicate record from a custom lightning form or through integration. CheckDuplicateRecord method in  CreateLeadController  class will return the duplicate record ids. After getting the duplicate record ID you can take appropriate steps to further use of this duplicate id based on your requirement. Go through the below steps to implement the scenario. Step 1 : Activate duplicate rule on Lead. Step 2 : Create a lightning form to create lead in salesforce and create a controller to check for duplicate record. LeadFormComponent.cmp <aura:component controller="CreateLeadController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexi