PDF Transfer from one task to another
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Good morning,
I am trying to attach a PDF from one TOLTASK to another. i have the blank PDF on the shipping task (or In Transit stage). User will open and sign PDF then resave it on that TOLTASK. Once the In Transit Stage is in Closed Complete, that newly signed PDF should now be attached to the Receiving task (or Received Stage).
This is the business rule I am using but it does not seem to be working.
(function executeRule(current, previous /*null when async*/ ) {
if (current.short_description != 'Ship') return;
if (!current.state.changesTo(3)) return;
var recv = new GlideRecord('alm_transfer_order_line_task');
recv.addQuery('alm_transfer_order_line', current.alm_transfer_order_line);
recv.addQuery('short_description', 'Receive');
recv.addQuery('state', '!=', 3);
recv.orderBy('sys_created_on');
recv.setLimit(1);
recv.query();
if (!recv.next()) return;
var att = new GlideRecord('sys_attachment');
att.addQuery('table_name', current.getTableName());
att.addQuery('table_sys_id', current.getUniqueValue());
att.addQuery('file_name', 'CONTAINS', '1311');
att.orderBydesc('sys_created_on');
att.setLimit(1);
var gsa = new GlideSysAttachment();
var bytes = gsa.getBytes(att);
if (!bytes) return;
gsa.write(
recv.getTableName(),
recv.getUniqueValue(),
String(att.file_name),
String(att.content_type),
bytes
);
})(current, previous);