LogoLogo
AboutSupport
3.1
3.1
  • Unifi User Documentation
  • Release
    • Release Notes
      • Unifi 3.1 Release Notes
      • Unifi 3.0 Release Notes
      • Unifi 2.2 Release Notes
      • Unifi 2.1 Release Notes
      • Unifi 2.0 Release Notes
    • Installation
    • Global Utility
    • Hotfix
  • Overview
    • Quick Tour
    • Supported Features
    • Application Modules
    • Data Model
  • Integration Guides
    • Outbound Incident Guide
      • Getting Started
      • Process
      • Integration
      • Connection
      • Create Scenario
        • CreateIncidentResponse Message
        • CreateIncidentResponse Fields
        • CreateIncident Message
        • CreateIncident Fields
        • Trigger
        • Test CreateIncident
      • Update Scenario
        • Response Message
        • UpdateIncident Message
        • UpdateIncident Fields
        • Test UpdateIncident
      • Resolve Scenario
        • ResolveIncident Message
        • ResolveIncident Fields
        • Test ResolveIncident
      • Build - Integration Level
      • Conclusion
    • Bidirectional Asynchronous Incident Guide
      • Getting Started
      • Process
      • Web Service
      • Integration
      • Connection
      • Create Scenario
        • Response Message
        • CreateIncidentReceipt Message
        • CreateIncidentReceipt Fields
        • CreateIncident Message
        • CreateIncident Fields
        • Trigger
        • Test CreateIncident
      • Update Scenario
        • Receipt Message
        • UpdateIncident Message
        • UpdateIncident Fields
        • Test UpdateIncident
      • Resolve Scenario
        • ResolveIncident Message
        • ResolveIncident Fields
        • Test ResolveIncident
      • Build - Integration Level
      • Build the Other Half
        • Move the Integration
        • Reconfigure the Connections
      • Conclusion
    • Incident Update Poller Guide
      • Polling
        • Poll Processor
        • Poller
      • Inbound Message
        • UpdateIncidentInbound Message
        • UpdateIncidentInbound Fields
      • Message Identification
      • Bond Identification
        • Edit Incident Form
        • Edit CreateIncident Message
      • Test Update Poll
      • Conclusion
    • Incident Multiple Message Poller Guide
      • Polling
        • Poll Processor
        • Poller
      • Inbound Messages
        • ResolveIncidentInbound Message
        • ResolveIncidentInbound Fields
      • Testing
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
      • Conclusion
    • Incident Create Poller Guide
      • Polling
        • Connection Variables
        • Poll Processor
        • Poller
      • Messages
        • CreateIncidentInboundReceipt Message
        • CreateIncidentInboundReceipt Fields
        • CreateIncidentInbound Message
        • CreateIncidentInbound Fields
      • Build - Integration Level
      • Test Create Poll
      • Conclusion
    • Incident Parent and Child Poller Guide
      • Polling
        • Connection Variables
        • Child Poll Processor
        • Child Poller
        • Parent Poll Processor
        • Parent Poller
      • Inbound Messages
      • Testing
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
      • Conclusion
    • Incident Attachment Poller Guide
      • Polling
        • Connection Variables
        • Edit Endpoint URLs
        • Get Attachment Poll Processor
        • Get Attachment Poller
        • Select Attachments Poll Processor
        • Select Attachments Poller
        • Edit Child Poll Processor
        • Edit Child Update Poller
      • Messages
        • AddAttachmentInbound Message
      • Testing
        • Test Outbound Scenarios
        • Test CreateIncidentInbound
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
        • Test AddAttachmentInbound
      • Conclusion
  • Feature Guides
    • Packager Feature Guide
      • Instructions
    • Error Handling Tools Feature Guide
      • Retry
      • Replay
      • Ignore
      • Repair
      • Pause and Resume
    • Unifi Test Assistant Feature Guide
      • Generating Tests
      • Running Tests
      • Exploring Results
  • HOW TO GUIDES
    • How to Handle Attachments
      • Message
      • Scripted REST Resource
      • Test AddAttachment
    • How to Setup an OAuth Connection
      • Identity Provider Instance
      • Identity Consumer Instance
  • Bonding
    • Bonds
    • Bonded Attachments
  • Transport
    • Transport Data Flow
    • Snapshots
    • Transactions
    • Stages
    • HTTP Requests
  • Configuration
    • Processes
    • Integrations
    • Connections
    • Messages
    • Message Scripts
    • Fields
    • Field Maps
    • Response Actions
    • Event Actions
  • Polling
    • Pollers
    • Poll Processors
    • Poll Requests
    • Large Response Payloads
  • Testing
    • Integration Tests
    • Test Scenarios
    • Test Scenario Data
    • Test Results
    • Test Scenario Results
  • Administration
    • Activity Logs
    • Data Stores
    • Properties
    • Scheduled Scripts
    • System Logs
    • Self-test
  • Scripting
    • Variables
    • Snippets
  • Troubleshooting
    • Attachments
      • New record attachments are not sent from Portal
      • Embedded attachments not being sent
      • Special characters in attachment file names
    • Development
      • Bonding to existing records
      • Copying an existing Unifi trigger rule doesn't work
      • Duplicate messages being sent
      • Deleted records are not packaged
      • Multipart Form Data
      • Undefined error when building an integration
    • Installation
      • Latest version of Unifi not accessible
    • Integration Responses
      • Transaction has been processed already
      • Initiating transaction not found for inbound receipt
      • Message has already been processed
      • Message ID not found
      • Message is not valid for this bond
      • Message name not recognised
      • Unable to identify message name from request
    • Other
      • Dynamic stage does not render
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Troubleshooting
  2. Attachments

Embedded attachments not being sent

There has been a change to GlideSysAttachment from when some of our original extract attachments scripts were written, and when now passing the base64 decoded string as a byte array to the global GlideSysAttachment.write() method. Unifi has specialised debugging and because of this, the byte array ends up as null when Unifi debug mode is off. We suspect this is because ServiceNow routes the variable through some coercion in the Rhino environment when passing it through Unifi which forces it to work. Without the debug mode turned on, the byte array is being passed through and for some reason that isn't clear, it is treated differently.

You need to update the extract attachment script to something similar below:

payload = (function extractAttachments(payload, request) {

  function saveAttachment(record, filename, content_type, data) {
    var id;

    if (typeof filename === 'undefined') {
      x_snd_eb.ws_console.warn('Ignoring attachment with missing filename attribute.');
      id = 'x-attachment-error-missing-filename';
    } else if (!filename) {
      x_snd_eb.ws_console.warn('Ignoring attachment with empty filename attribute.');
      id = 'x-attachment-error-filename-is-empty';
    } else {  
      // use x_snd_eb scope to force using the scoped version of GSA
      id = new x_snd_eb.GlideSysAttachment().writeBase64(record, filename, content_type, data);
      x_snd_eb.ws_console.trace('Extracted attachment [' + filename + ':' + content_type + ']' +
        ' to record [' + id + ']' +
        ' for [' + record.getTableName() + ':' + record.sys_id + ']');
    }

    // return the original tag with the sys_id of the new attachment record
    // so Unifi can pick it up in processing later on
    return '[x-attachment-data sys_id="' + id + '" /]';
  }

  var obj = JSON.parse(payload);

  obj.attachment.data = saveAttachment(
    request, 
    obj.attachment.filename, 
    obj.attachment.mime_code, 
    obj.attachment.data
  );

  return JSON.stringify(obj);
})(payload, request);
PreviousNew record attachments are not sent from PortalNextSpecial characters in attachment file names

Last updated 3 years ago

Was this helpful?