Working with attachments - Riada-AB/InsightManager GitHub Wiki

This example shows how to:

  1. How to get all attachments from an object:

ArrayList<SimplifiedAttachmentBean>sourceAttachmentBeans = im.getAllObjectAttachmentBeans(sourceObjectKey)

  1. Filter out a specific one based on name:

sourceAttachmentBeans = sourceAttachmentBeans.findAll{it.originalFileName == fileName}

  1. Attaching the file to another object

SimplifiedAttachmentBean newSimplifiedAttachmentBean = im.addObjectAttachment(destinationObjectKey, file, fileName, "Moved from object:" + sourceObjectKey, true)

  1. Deleting the attachment from the original object

im.deleteObjectAttachment(beanToBeMoved)

See the complete code here