Signing Date on HTML Document Templates

leahdany
Giga Guru

Hello,

 

Is there a way within an HTML Document Template to add/map a signing date? I know this can be done on a PDF Document Template, but since what I'm generating is an offer letter there are dynamic field values and the ability to edit the document after previewing it before the document task is initiated.

 

I need a way to record the signing date from the subject person before the final PDF gets generated. Any ideas?

1 ACCEPTED SOLUTION

Here's the BR conditions and script that I use.

 

jeffiral_0-1724021217169.png

 

 

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

    var htmlBody = current.body.toString();

    var curDate = new GlideDate();
    var formattedDate = curDate.getByFormat('dd-MMM-yyyy');
    var actionType = current.participant.toString();

    if (actionType == '1450bf7c937f42d0b6c1b92b1bba10ef' && current.state.changesTo(3)) {
        // Manager Acknowledgement and state changes to Closed
        htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateManagerAcknowledgement</span>', '<span style="color: #000000;">' + formattedDate + '</span>');

    } else if (actionType == '1200bbfc937f42d0b6c1b92b1bba10bc') {
        // Employee Acknowledgement
        if (current.state == 1) { // Ready
            var prevTask = current.previous_task.sys_id;
            var prevtskQuery = new GlideRecord('sn_doc_task');
            if (prevtskQuery.get(prevTask)) {
                var prevtskDate = prevtskQuery.getValue('closed_at');
                var prvformattedDate = new GlideDate(prevtskDate).getByFormat('dd-MMM-yyyy');
                htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateManagerAcknowledgement</span>', '<span style="color: #000000;">' + prvformattedDate + '</span>');
            }
        }

        if (current.state.changesTo(3)) { // Closed
            htmlBody = htmlBody.replace('<span style="color: #ffffff;">DateEmployeeAcknowledgement</span>', '<span style="color: #000000;">' + formattedDate + '</span>');
        }
    }

    current.setValue('body', htmlBody);
    current.update();

})(current, previous);

 

 

View solution in original post

8 REPLIES 8

Akash4
Kilo Sage
Kilo Sage

You can write a static Doc template script and add it to the HTML Doc Template. But to get the signing date it must be dynamic & travel through PDF mapping based on date of sigining and this cannot be done beforehand in HTML Document Template.

Hope this answers!

Regards, Akash

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

abirakundu23
Mega Sage

Hi @leahdany ,

In order to achieve the dynamically signing date of Subject Person after completion of Signature can't be possible in HTML document template. You can achieve this by PDF document template to populate dynamic date after subject persons signed. Similar requirement also received from our client.

Please mark helpful & correct answer if it's really worthy for you.

leahdany
Giga Guru

@Akash4 @abirakundu23 I know I can set the signing date on a PDF, but I haven't found a way to edit and sign the PDF before initiating the document task.

 

When I use Managed Documents for the PDF I can't edit the PDF before initiating the document tasks. This is why I was using HTML because I could edit prior to initiating the document task.

 

When I use HR Managed Documents for the PDF I can edit and sign, but I can't initiate document tasks because it's not a managed document.

 

I'm looking for a solution that will allow me to edit and sign the document then initiate the document task while having the signing date mapped.

To this point - "I can't initiate document tasks", you can try using a logical script if it's allowed. As described, use the HTML Document for editing required content, then trigger a Document task using a Business Rule or Flow.

Hope this helps!
Regards, Akash
_____________________________________________________________________________
Please mark it as helpful 👍 or Accept Solution ✔️ based on the response to your query.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.