New record attachments are not sent from Portal

This issue is caused by the fact that the record users add attachments to in the portal is not in fact the record being integrated by Unifi. It's a temporary record which ServiceNow will then move the attachments from to the requested item/target record of a record producer at a later time.

An issue arises here though as a Unifi create message can be triggered before ServiceNow moves the attachments. If this happens then Unifi will not send the attachments.

To get around this issue we can trigger a new ServiceNow event to be fired when Unifi sends a create message. This will then give time for the attachment to be added to the request. We will use a script action to then force update any attachments on the requested item, thus triggering Unifi as if the attachment was just added.

Follow these steps:

  • Create a new event, say, unifi.send.portal.attachments.on.create

  • Create a new Script action, which runs on the above new event, with the following code:

var attachments;
attachments = new GlideRecord('sys_attachment');
attachments.addQuery('table_sys_id', '=', current.sys_id);

while ( {
  • Modify the create message to trigger the event, i.e. in the Source to stage script of the CreateRequest message, add the following code below the autogenerated scripts:

gs.eventQueue('unifi.send.portal.attachments.on.create', source, '', '');