zAgileConnect Flow Action - Create Issue
Please note that zAgileConnect license is required for a user to invoke this Action. Additionally the user must have the “zAgileConnect Subscription User“ permission set and access to the “ZCProcessIssueCreate“ apex class.
You can create an Issue by using Salesforce Flow and adding the “Create Issue“ action to your flow. The action has the following fields:
Create Issue Action Fields
Field | Type | Required | Description |
---|---|---|---|
connectionId | String | If multilple Jira instances are connected (for zAgileConnect Release 1.15.x and higher), specify the connection id (j00, j01, etc). Leave empty to use the default Jira connection. | |
entityId | String | The Salesforce record Id to link to the new Jira Issue. | |
projectKey | String | Jira Project Key. | |
issueTypeName | String | Jira Issue Type names (e.g. Bug, Task, Improvement). | |
summary | String | A brief one-line summary of the Issue. | |
description | String | A detailed description of the Issue. | |
environment | String | The hardware or software environment to which the Issue relates. | |
label | String | Label to which this issue relates. Note this field accepts a single value only. | |
priorityName | String | The importance of the Issue in relation to other issues (e.g. High, Low, Lowest). | |
duedate | Date | The date by which this Issue is scheduled to be completed. | |
affectVersionName | String | Project version for which the issue is (or was) manifesting. Note this field accepts a single value only. | |
fixVersionName | String | Project version in which the issue was (or will be) fixed. Note this field accepts a single value only. | |
componentName | String | Project component to which this issue relates. Note this field accepts a single value only. | |
reporterName | String | JIRA ON-PREM ONLY the Jira Server or Data Center username who entered the Issue into the system. Leave blank to use the Jira account associated with the current Salesforce user (if the current Salesforce user had previously authenticated to Jira directly, otherwise it will be the Jira Integration User account ) | |
reporterId | String | JIRA CLOUD ONLY the Jira Cloud user accountId who entered the Issue into the system. Leave blank to use the Jira account associated with the current Salesforce user (if the current Salesforce user had previously authenticated to Jira directly, otherwise it will be the Jira Integration User account ) | |
assigneeName | String | JIRA ON-PREM ONLY the Jira Server or Data Center username to whom the Issue will be assigned. Leave blank to let Jira auto assign the Issue. | |
assigneeId | String | JIRA CLOUD ONLY the Jira Cloud user accountId to whom the Issue will be assigned. Leave blank to let Jira auto assign the Issue. | |
customfieldsJSON | String | To populate custom fields for an Issue, use the field customFieldsJSON in which you can use a formula for building the JSON as string. More details below. | |
impersonateUser | Boolean | DEPRECATED this field is deprecated and should not be used. |
If more than one Component, Label, FixVersion or AffectsVersion is required to be passed to Jira when creating an Issue, use instead the zAgileConnect Apex API for creating Issues.
Default Create Issue Fields Mapping
By default the Create Issue action uses the values mapped in the Step 6 - Select Salesforce fields to send to Jira Issues.
For example if summary and description are mapped in Step 6, then the Create Issue action will use those values for those fields when creating the Issue if no values are provided in the Flow Builder.
For Jira custom fields, the custom fields defined in Flow Builder in the customfieldsJSON override all the custom fields mapped in Step 6. So custom fields can be either mapped in the Step 6 or defined in the customfieldsJSON but not both, if both are defined only custom fields in customfieldsJSON will be sent to Jira.
Error Handling
This invocable action executes callouts to Jira API and so is executed in an asynchronous transaction. For this reason this action does not return any result. Errors during Issue creation are sent via email to the Salesforce user for whom the Flow is being executed and will also show in the “Related Jira Issues“ section for the Salesforce record provided (provided as entityId in the Flow Builder).
Setting Custom Fields Data
Jira Issue custom fields can be set using the customfieldsJSON field. This fields expects a String that represents a JSON Object, each attribute in the object must be the custom field Id (customfield_
). For example:
{
"customfield_11001" : <custom field value>,
"customfield_11005" : <custom field value>,
"customfield_11008" : <custom field value>
}
the expected custom field value depends on the type of the custom field, to find the custom field Ids use the following REST API provided by Atlassian:
Create meta for Jira Cloud
https://{jiraBaseUrl}/rest/api/3/issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}Create meta for Jira Server or Data Center
https://{jiraBaseUrl}/api/2/issue/createmeta/{projectIdOrKey}/issuetypes/{issueTypeId}
Replace {jiraBaseURL}, {projectIdOrKey} and {issueTypeId}, to find the Issue Type Id see Finding the ID for Issue Types.
for example https://example.atlassian.net//rest/api/3/issue/createmeta/SFTEST/issuetypes/1 will produce:
Find the metadata for the custom field by name (Product Code in the example above) in the response.
Some field types have allowed values in the metadata, for example for select lists, checkboxes, etc. You need to get the allowed value Id in order to pass it to Jira. In the example below there is a Select List (single choice) Jira custom field called “Case Status”, with 3 allowed values (New, On Hold, Escalated), to pass the “New“ value to Jira for Issue creation you need to grab and use the Id “10103“.
The examples below show how to set the values for different types of custom fields (you can find the field type in Jira Settings → Issues → Custom Fields ).
TextField - FreeTextField
Text Field (single line) or Text Field (multi-line)
"customfield_11050" : "Value that we're putting into a Free Text Field."
DatePickerField
"customfield_10002": "2011-10-03"
DateTimeField
"customfield_10003": "2011-10-19T10:29:29.908+1100"
This format is ISO 8601: YYYY-MM-DDThh:mm:ss.sTZD
NumberField
"customfield_10010": 76.68
URLField
"customfield_10016": "http://www.zagile.com"
SelectList
Select List (single choice)
"customfield_10013": { "id": "10103" }
RadioButtons
"customfield_10012": { "id": "10105" }
ProjectPicker
"customfield_10011": { "id": "10001" }
GroupPicker
Group Picker (single groups)
"customfield_10005": { "name": "jira-developers" }
SingleVersionPicker
Version Picker (single version)
"customfield_10014": { "id": "10000" }
MultiSelect - Checkboxes
Select List (multiple choices) or Checkboxes
"customfield_10008": [ {"id": "10040" }, {"id": "10050" }, {"id": "10060" }]
VersionPicker
Version Picker (multiple version)
"customfield_10018": [{ "id": "10110" }, { "id": "10120" }, { "id": "10130" }]
MultiGroupPicker
Group Picker (multiple groups)
"customfield_10007": [{ "name": "admins" }, { "name": "jira-developers" }, { "name": "jira-users" }]
CascadingSelectField
Select List (cascading)
"customfield_10001": {"id": "10210", "child": {"id":"10510"}}
UserPicker
For Jira Server and Data Center pass the username.
"customfield_10017": { "name":"jhuertas"}
For Jira Cloud pass the Account Id
"customfield_10017": { "id":"557058:e090d05a-0f5d-4a11-8cc1-0a0804686861"}
MultiUserPicker
For Jira Server or Datacenter pass usernames.
"customfield_10009": [{"name": "charlie" }, {"name": "bjones" }, {"name": "tdurden"}]
For Jira Cloud pass Account Ids
"customfield_10009": [{"id": "557058:e090d05a-0f5d-4a11-8cc1-0a0804686861" }, {"id": "557058:e090d05a-0f3d-2a44-1cc1-0a0804664329"}]
For example to pass 3 custom fields of types text, select list (single choice) and a number field:
{
"customfield_11001" : "Value that we're putting into a Free Text Field.",
"customfield_11005" : { "id": "10103" },
"customfield_11008" : 76.68
}
It is recommended to create a Text Template resource in the Flow Builder to build the JSON String, make sure to edit it in “View as Plain Text” mode:
and pass the text template as the customFieldsJSON field in the Flow Action:
It is also possible pass Salesforce record fields by inserting resources in the text template, for example to pass the Case Subject into the text customfield_10200:
Example Flow to Create an Issue in Jira when Case Status changes to Escalated
The following example will create an Issue every time the Case status is updated to the “Escalated“ status.
In Salesforce → Flows create a new Flow from scratch
Select “Record-Triggered Flow“ and create, then select the Case Object and the conditions as follows:
Add the “Create Issue” Flow Action
Make sure to pass the Case ID in the entityId field
Set the Jira Project key and Issue Type (relevant to your Jira) and map summary and description fields from Case fields:
Finally Save and Activate the flow. Then go to a Case and update the Case Status to “Escalated“, a new Jira Issue must be automatically created, refresh the page to view the Issue in the Related Jira Issues Section.