We are still using the older .bsh scripts, this is an excerpt fro the script that handles the moving of the attachments:
- Code: Select all
/* Move any attachments */
if (task.hasAttachments()) {
int notCopied = 0;
Map ma = task.getAttachsTaskOrMessage();
Set s=ma.entrySet();
Iterator it=s.iterator();
while (it.hasNext()) {
Map.Entry m = (Map.Entry)it.next();
SecuredTaskAttachmentBean key = (SecuredTaskAttachmentBean)m.getKey();
boolean value = (boolean)m.getValue(); // True for Task attachment, False for Message attachment
int maxSize = Integer.parseInt(UDFManager.getTaskUDFValue(sc, configTaskId, "maxAttachmentCopySize"));
if (key.getSize() < maxSize*1024*1024) {
ByteArrayInputStream data = new ByteArrayInputStream(AttachmentManager.getAttachment(sc, key.getId()));
AttachmentManager.createAttachment( sc,
newTaskId,
null,
key.getUserId(),
key.getName(),
key.getDescription(),
data);
AttachmentManager.deleteAttachment( sc, key.getId());
} else {
notCopied++;
}
}
if (notCopied > 0) {
newMsgDesc = "There is one large file";
if (notCopied > 1) {
newMsgDesc = "There are " + Integer.toString(notCopied) + " large files";
}
newMsgDesc = newMsgDesc + " attached to the original report (#" + MyTaskNumber + ").";
MessageManager.createMessage(sc, newTaskId, newNoteId, newMsgDesc,
null, null, null, null, null, null, null, false);
}
}
Even if the attachment user isn't randomly set, it seems to default to the user running the script, I'd like it to be the original user that uploaded the attachment. How can I do that?