Attach updated PDF from previous document task to new document task

kristenmkar
Mega Sage

Good evening! 

 

We are currently utilizing the Digital Signature Signing type for a document template, and I was able to configure it to work with participants (we have somewhat of a workaround in place because our F5 blocks the actual SN PIV/CAC signature)- however, I noticed that when the document tasks are created via the "Automatically initiate document tasks" they do not pull in an updated pdf from the last user filling it out/signing it.  So when someone signs the document and the next task is created, they are signing a new version of the document - which defeats the purpose of passing it around via document tasks. Do you guys have any suggestions or ideas on how I can push the previous pdf/attachment from the last document participant to the next and so on? Most of the Digital Signature Flows and rules are OOTB, but wondering if I can maybe create a business rule or replicate the flow and add this piece in? 

 

Thank you! 🙂 

1 ACCEPTED SOLUTION

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @kristenmkar 

Copy the signed PDF

Use either the Attachment API or GlideRecord to find the signed PDF on the current task and attach it to the next:

function copySignedPdf(fromTask, toTask) {
    var attGR = new GlideRecord('sys_attachment');
    attGR.addQuery('table_sys_id', fromTask.sys_id);
    attGR.addQuery('table_name', fromTask.getTableName());
    attGR.query();
    while (attGR.next()) {
        var newId = GlideSysAttachment.copy(
            attGR.getTableName(), fromTask.sys_id,
            toTask.getTableName(), toTask.sys_id,
            attGR.file_name
        );
    }
}

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 


View solution in original post

3 REPLIES 3

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @kristenmkar 

Copy the signed PDF

Use either the Attachment API or GlideRecord to find the signed PDF on the current task and attach it to the next:

function copySignedPdf(fromTask, toTask) {
    var attGR = new GlideRecord('sys_attachment');
    attGR.addQuery('table_sys_id', fromTask.sys_id);
    attGR.addQuery('table_name', fromTask.getTableName());
    attGR.query();
    while (attGR.next()) {
        var newId = GlideSysAttachment.copy(
            attGR.getTableName(), fromTask.sys_id,
            toTask.getTableName(), toTask.sys_id,
            attGR.file_name
        );
    }
}

Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 


This works awesome! Used it within a business rule 🙂 thanks so much for the help! 

Good morning!

 

The only issue I seem to be having with this is if there are multiple document tasks and attachments - it will only pull up the first attachment that was saved. Is there anyway to modify this so it is the most recent pdf? 

Thank you!