CopyAttachmentToCase
CopyAttachmentToCase() function copies a selected attachment from the current case into another case and attaches its copy to the document list. Attachment can also be added into document-type field, if the third parameter is provided. In case there is already another attachment in the target field, it is moved into document list.
Syntax
CopyAttachmentToCase(attachmentId, caseId, targetFieldName);
CopyAttachmentToCase(attachmentId, caseId);
CopyAttachmentToCase(fieldName, caseId, targetFieldName);
CopyAttachmentToCase(fieldName, caseId);
CopyAttachmentToCase(attachmentName, caseId, targetFieldName);
CopyAttachmentToCase(attachmentName, caseId);
Function arguments
- attachmentId – (String) an ID of the attachment that is about to be copied;
- fieldName – (String) a name of the field with attachment on the current case;
- attachmentName – (String) a name of the attachment existing on the current case’s document list;
- caseId – (String) an ID of the case to which the attachment should be copied;
- targetFieldName – (String) [optional] a name of the document-type field on the case where exactly the attachment will be copied. If an argument is not provided, the attachment is added into the case document list.
Return value
This function returns Boolean.
Returns true if copying was successful, otherwise returns false.
Examples
Example 1:
This will copy the attachment with id 200 from the current case into the case with id 1000. The attachment is about to be copied into the field called „Invoice”.
if (CopyAttachmentToCase(200,1000,"Invoice")) { }
Example 2:
This will copy the attachment with id 200 from the current case into the case with id stored in variable iCaseID. The attachment should be copied into the document list.
iCaseID = 1000; if (CopyAttachmentToCase(200,iCaseID)) { }
Example 3:
This will copy the attachment placed in the field „InvoiceDocument” from the current case into the case with id 1000. The attachment is about to be copied into the field called „Invoice”.
if (CopyAttachmentToCase("InvoiceDocument",1000,"Invoice")) { }
Example4:
This will copy the attachment „Invoice.tif” located on the document list of the current case into the case with id 1000. The attachment is about to be copied in the field called „Invoice”.
if (CopyAttachmentToCase("Invoice.tif",1000,"Invoice")) { }
See also: MoveAttachmentToCase()