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

PDF Attachment

coreyhirsch
Tera Contributor

I am looking to attach a PDF to the Transfer Order Line Task (specifically the shipping line task). This document, once filled out and the Transfer Order Line Task is closed, must then be transferred to the received line task. I've never dealt with PDF attachments before so I am not sure how to approach this.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@coreyhirsch 

So it's a static file which agent will add to Transfer Order Line Task?

if yes then you can use after business rule on Closure of Transfer Order Line Task and use GlideSysAttachment.copy() logic to copy it to whichever record you want.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Below is the script I used and it worked, however, it is attaching the PDF to every task. I only want it to attach to the task when the stage is in "In Transit".  The commented out portion (line 2) is how I tried to do this but when I add it in, it doesn't do anything except PDF doesn't attach at all. When I comment that out, the PDF attaches to every task.

This business rule is on the alm_transfer_order_line_task

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

// if (String(current.getValue != ('stage') || '') != 'in_transit') return;

 

    var gr = new GlideRecord("sys_properties");

    gr.addQuery("name", "order.transfer.pdf.holder"); // name of property in query

    gr.query();

    if (gr.next()) {

        new GlideSysAttachment().copy('sys_properties',gr.getUniqueValue() , current.sys_class_name, current.getUniqueValue());

    }

 

})(current, previous);

coreyhirsch
Tera Contributor