Posts

Showing posts from December, 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