How to generate Signature using LWC?

on

|

views

and

comments

Hello #Trailblazer,

In this blog post, we will learn how to capture the signature using Salesforce LWC Component.

Capturing the signature is very important these days as most of the time business is dealing with the Direct customers like you and me.

For example, you are working for a company that is installing the solar system to the customers. So after installing the solar system they would require the customer signature and for that purpose we will develop our lightning web component.

The Solution

To capture the signature, we will use HTML5 Canvas which will be used to draw the signature

Link to Canvas API

Step1 – Create Apex Class

The first step is to create the apex class which will create the ContentVersion and Content Document Link

The Apex Class will be responsible for inserting the content version and content document link

Step2 – Create Lightning Web Component

Now, time is to create the Lightning Web Component which will contain the html canvas element. like below

<canvas name="canvasItem" style="border:2px solid rgb(136, 135, 135); background: transparent;"></canvas>

In the above code you can see that we are using a canvas and in our javascript we will be using this canvas to get the context and generate/draw a signature in 2D surface.

Here is the complete code for Lightning Web Component

Note:- Read the code comments

Places where solution can be used

  1. Record Page
  2. Flow
  3. Community

Test the Solution

To test the solution, use this component inside the record page for any object and then try to capture signature.

Thanks for reading 🙂

Amit Singh
Amit Singhhttps://www.pantherschools.com/
Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion
Share this
5 out of 5

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Not able to sign in Mobile.Hey Amit, Thanks for this, it works without any issue in desktop but it doesn't work for touch devices or mobile devices , can you please suggest workaround.ThanksHow to generate Signature using LWC?
5/5

Stuck in coding limbo?

Our courses unlock your tech potential