Attachments as retrieveData() return values

In some cases, it may be preferable be return an attachment from retrieveData(). The logic to create and/or retrieve an attachment will be implementation specific, but after the attachment is known, its information can be returned.

To provide an attachment, retrieveData() should return an object along the lines of:

{
       contents: "attachment-sys-id",
       contentType: "sys_attachment"
}
Below is an example that extends on the previous example, but saves the response body of the REST Message to the integration process record, and then returns that attachment identifier as the contents of the return object.
Figure 1. Return attachment from retrieveData
Sample script with attachment as retrieveData() return value