Skip to main content
Skip table of contents

zAgileConnect API – Sending Attachments to Jira Issues from Salesforce – Usage & Examples

Requires the user executing the API to have a valid zAgileConnect license

Build attachments reference array.

zAgileConnect supports three types of files for sending to Jira Issue:

  • ContentDocument
  • Document
  • Attachment

To send files to Jira Issue, create an array of the class ZCBeans.SalesforceAttachment as follows:

CODE
List<zsfjira.ZCBeans.SalesforceAttachment> attachments = new List<zsfjira.ZCBeans.SalesforceAttachment>();

The instance of ZCBeans.SalesforceAttachment contains the File ID and the Issue Key (or issue keys) where you want to send the file.

To send to a single Issue:

CODE
Id fileId = ...;
String issueKey = ...;
zsfjira.ZCBeans.SalesforceAttachment attachment = new zsfjira.ZCBeans.SalesforceAttachment(fileId,issueKey);

To send to multiple Issues:

CODE
Id fileId = ...;
Set<String> issueKeys = ...;
zsfjira.ZCBeans.SalesforceAttachment attachment = new zsfjira.ZCBeans.SalesforceAttachment(fileId,issueKeys);

The ID should be of an object of type ContentDocument, Document or Attachment.

Sending Attachments to Jira

The Send request is an asynchronous task and a response is posted following completion. You may specify an ID of the object where you want any errors to be posted.

CODE
Id onErrorEntityID = ...; 
List<zsfjira.ZCBeans.SalesforceAttachment> attachments = ...;
zsfjira.ZC.Issues.sendAttachments(onErrorEntityID, attachments);

Validate Successful Request:

The method ZC.Issues.sendAttachments returns the result of the operation

CODE
...
zsfjira.ZCBeans.AttachmentRequestResult requestResult = zsfjira.ZC.Issues.sendAttachments(onErrorEntityID, attachments);
if(requestResult.hasError()){
	System.debug(System.LoggingLevel.ERROR,requestResult.getErrorMessage());
}

Sending attachments to a different Jira Connection

In the example above the Jira connection Id was not specified when sending the attachment, as a result, the attachment will be sent in the Jira marked as default on your zAgileConnect settings:

For specifying a different Jira you must know the Connection ID related to that Jira, accessible via zAgileConnect Settings:

The Jira Connection ID is a unique identifier for specifying a Jira when calling the zAgileConnect API.  For example, to send an attachment to the Jira JccJiraCloud, specify its Jira Connection ID j01 when calling the method:

CODE
zsfjira.ZC.Issues.sendAttachments('j01', onErrorEntityID, attachments);
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.