The CreatorCon Call for Content is officially open! Get started here.

Lifecycle activity - Auto fill E-signature template

Bobbie Patrick
Tera Contributor

Hi all,

 

I'm in the process of creating a POC for a customer, we have created a Lifecycle event for onboarding a new hire.

 

One of the requirements is to generate an offer letter for the new hire to sign, the details of the offer letter needs to be populated from the HR case and the HR profile of the user.

 

We have created a PDF template and mapped the relevant fields to auto fill the form. the activity template has been setup as per the following snippet.

BobbiePatrick_0-1704359940999.png

 

We are using E-signature document over template as templates don't auto fill

 

While testing this however, when the task is generated for the new hire - the E-signature template field is empty on the task and on the employee portal the new hire receives errors.

BobbiePatrick_1-1704360809020.png

Looking into the errors - they are being driven by the fact that the E-signature template field is empty.

 

Looking at the tables the template can pull from it doesn't look like we can achieve what the customer is looking for

 

Our document sits on the sn_doc_template table

HR task template:

E-signature document looks at the sys_attachment table

E-signature template looks at the sn_esign_configuration table

 

Question - is it the case that ServiceNow cannot generate an auto fill e-sign document on a HR task as part of a Lifecycle event?

 

Any help or guidance would be much appreciated.

 

3 REPLIES 3

Phong Lo
Tera Guru

Hi Bobby, did you find a solution for this?

DhanalakshmM
Tera Contributor

E-Signature template field has to be selected. However, the PDF is not being auto filled for the HR Task generation.

DhanalakshmM
Tera Contributor

The other way to attach the attachment in the HR Task record is to use Business rule and have this code 

 

(function executeRule(current, previous /*null when async*/ ) {

    try {

        // Put your PDF Template sys_ids here

       //Property to store the document template sys id

        var resignation = gs.getProperty('');

        //var pdfUtil = new PdfTemplateUtilsSNC();

        // Decide which template to use

        // Generate PDF and attach to the task

        var pdfAttachmentId = new sn_doc.GenerateDocumentAPI().generateDocumentForTask(current.sys_id, resignation, current.short_description + "");

        if (pdfAttachmentId) {

            gs.info("PDF successfully attached to task " + current.number);

        } else {

            gs.error("PDF generation failed for task " + current.number);

        }

        // Log the error

 

    } catch (ex) {

        gs.error("Exception in PDF generation: " + ex.message);

    }

 

})(current, previous);

 

 

This will attach the attachment with dynamically populating the values within the PDF document. Also have the task type as 'Mark as complete' instead e-signature