Thursday, 11 April 2024

How to get a salesforce document digitally signed via KAiZEN ?

Using AYAN KAiZEN, businesses can digitally or electronically sign a contract or deal or any confidential document in a secured way. There is no need for the sales team to send any physical documents for signing, as it will take time and can delay the process. 

Signers can create/draw/upload a secure and verifiable signature, which can be used on any device to digitally sign or embed sign to a specific location on the documents.

Salesforce Admins / Developers can easily integrate KAiZEN API's to enhance the e-signing capabilities for the company. Additionally, sales team can track the status of the signed documents and can send the documents to multiple signers in the hierarchy model.

KAiZEN API's can be easily integrated into Apex, Aura Components, or LWC and offers wide range of API to manage different actions.


Few simple steps to get a document digitally signed via KAiZEN:

Step 1: Identify a File or attachment or PDF (visualforce page renderAs PDF) which needs to be digitally signed by single or multiple users.  Once it is identified, then use below line of code to convert the blob into base64.

String FileData = EncodingUtil.base64Encode(<< blob Content >>);


Various ways to get blob content:

1. If using visual-force page for pdf creation, then use below lines of code: 

PageReference pageRef = new PageReference('/apex/ServiceReportPDF');
Blob  pdfBlob  = pageRef.getContent(); 
String pdfBase64 = EncodingUtil.base64Encode(pdfBlob);


2. If using existing File or attachment, then query the File / Attachment

Attachment att = [Select Id, Body from Attachment limit 1]; // or add some filters
String pdfBase64 = EncodingUtil.base64Encode(att.body);


Step 2: Identify the users which needs to sign the document along with their levels or order hierarchy. Order means the sequence in which the signers will sign the document. Person with Order 2 will sign only after person with order 1 has signed.

Let's define the below two users which the order of signing. 

Signer Information
Signer NameOrderSigner Email
Mr Harjeet1testmail@gmail.com
Mr Gurleen2sales@ayansoftwares.com

Step 3: Need to make a secure HTTP Callout to call the Kaizen "Initiate Sign API" request as per the below details:

HTTP Request Parameters
Paramters NameValue
Content-Typeapplication/json
MethodPOST
Endpointhttps://fa-kaizen-prod.azurewebsites.net/api/Sign/RequestStr?code=RTa1A0GW5Yl92OF54-73lRqglLFCt_0pVcg86hWf1EjtAzFuNROcdA==
BodyJSON Body with parameters

Request Body Parameters
Paramters NameDescriptionRequired?
docContentBase64 Content for the PDF FileYes
docNameName of the FileYes
appTokenUnique Code to initiate the requestYes
requesterEmailEmail address of the person initiating the requestYes
requesterNameName of the person initiating the requestYes
descriptionDescribes the documentNo
signersAn array of the signers who needs to sign the document in the pre-defined order.Yes
CallBackURLCallbackURL defines the url on which the Kaizen should send a response once all the signers signs the document. It can be webservice url of Salesforce or any external page.

Eg:  https://duumy.my.salesforce- sites.com/services/apexrest/KaizenCallbackURL/
No
docDescriptionDescribes the documentNo


Sample HTTP Request:
HttpRequest request = new HttpRequest(); request.setEndpoint( << Initiate Sign Endpoint URL >> ); request.setMethod('POST'); request.setHeader('Content-Type', 'application/json'); request.setBody( << JSON Body as shown below >> ); request.setTimeout(120000);

Sample JSON Body:
{
"docContent": "<< Base64 Content for the PDF File. Refer Step 1>>",
"docName": "TestBase64File",
"appToken": "01HQMDX-YCP019-Z2P3SX-QPSB53-8B4A3F-BC40B8-B10908-FB2FF4-A",
"requesterEmail": "mishu67777@gmail.com",
"requesterName": "Mohit Bansal",
"description": "Sales Contract Document",
"signers":[
{
"signerEmail": "testmail@gmail.com",
"signerName": "Mr Harjeet",
"order":"1"
},
{
"signerEmail": "sales@ayansoftwares.com",
"signerName": "Mr Gurleen",
"order":"2"
},

],
"CallBackURL": "<< callback url >>
"docDescription": "Sales Contract Document"
}


Sample HTTP Response:
{
"FailRules": [],
"Data": {
"SignRequestId": "01HV6MEARQD3X8ZXXX5FR3YDB8",
"RequestNo": "KAiZEN-118"
}

} 

Once the request is submitted, it will send a response with the request Id. If the callback url is configured, it will send a signed copy of the document on the defined url, once all the signers will sign the document.


Step 4:  Once the request is sent out to the signers, each signer will receive an email to sign the document in the order as defined in the request.

Let's see how the signing part works:

A. Open the kaizen email request sent for e-signing.


B. Click on the button "Click here to Sign" and it will open the document in the kaizen editor to sign.



C. Requestor can define the location where signer needs to sign.  It can defined in two ways:

a. In the PDF, add a hidden text with keyword "KAIZEN1" or "KAIZEN2" or KAIZEN3",  where KAIZEN is a hardcode keyword and number sequence is the order of the signer.

b. Click on "+ Signature" button and it will open a popup where signer can draw or upload any signature.





D. Once signed, click on the submit button.




E. In the same way, all the defined signers will sign the document. Once all the signers complete the signing, it will perform the below actions:
   i.  Send an individual email to all the signers with the signed document
   ii. Send the signed copy of the document on the callback url defined.


All the requests which are initiated or signed can be tracked inside the customer portal of Kaizen. 
 

Benefits of digitally signing with AYAN KAiZEN:
1. User can easily integrate apis in Salesforce via apex, AURA or directly in FLOW.
2. Each sign request can send request to single or multiple users in the order of their hierarchy.
3. All the signs of the signers has status of verified signature by digitial approved certificate of AYAN Softwares.
4. Secure and reliable platform.














No comments:

Post a Comment