Automatically add reporters and share work items to JSM Cloud Organizations
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
Learn to automate setting an organization field and adding customers to organizations based on reporter membership.
Solution
A scenario of how this knowledge article can be applied if:
You have a Jira Service Management project, and this project is only intended for a single Organization/Company.
You want every request created in this project to automatically be shared with all the members of the Organization, so add that Organization in the Organization field.
If the reporter is not part of the Organization yet, the automation will make sure to add the reporter as a member of the Organization.
This way, all other users/members of that Organization will be notified when a new ticket/request is created within the project.
This article will use the JSM REST API. The detailed steps to create the automation rule and its conditions will be presented further in the article. You can also import the example rule created for this article.
Overview of the Automation Rule
We will start by creating the automation rule for this action. To do so, follow the steps below. There are four different parts to the rule.
To create a new rule:
From your service project, select Project Settings > Automation.
Select Create rule in the top-right corner.
Select a trigger for the rule.
Select "Issue created" from the trigger settings and select Save.
Select New component and choose New condition. "If block" should be selected.
Select the "User condition" and configure accordingly.
Select "New action" and choose "Edit Issues".
Repeat steps 5-7 for the "else-if block".
Select "New action" on your else-if block. Configure this step as shown below.
Select Save.
Give your rule a name, then select Turn it on.
Part 1: Tools and Components
Selecting Trigger
Automation rules in Jira Cloud contain a number of triggers to use. For this rule, we will need the “Issue Created“ trigger.
Creating the If/else Block
In the rule, we’re checking whether the reporter is a member of a certain customer organization. This will contain multiple options, so we will use the “If/else block“ condition.
Checking the user’s membership
To check whether a user from a user picker field (Reporter), “User condition“ can be used.
This condition verifies whether a user is present or belongs to a specific group. You can include more criteria and choose whether all or any of them need to be met.
Executing the action
In this rule, there will be two actions to be used. The initial step involves considering the positive condition, which entails including the customer as a member of the targeted customer organization. For this purpose, we will be using the “Edit Issue“ action.
Edit the current issue by selecting the field you want to modify and the value you want to add. In Jira Service Management, you have the ability to edit both Jira fields and Assets fields. To gain a deeper understanding of Assets in Jira Service Management, please refer to this link.
Part 2: Prerequisite information
Set up basic authentication for the API.
Create an API token following these instructions here: Get an API token.
Generate the base64 encoded authorization following the instructions here: Supply basic auth headers.
Getting the organizationID
You can get the “organizationID” by calling the following endpoint.
https://<YOUR-SITE>.atlassian.net/rest/servicedeskapi/organization
Part 3: Adding a reporter as part of the Organization member
The second action we will take if the user is not part of this customer organization is the “Send Web request” action.
Sends a web request to notify another system when a rule is executed. You have the option to configure this action to return response data that can be utilized in a subsequent action.
Create the Web request
Add an action: Send web request.
Web request URL:
https://<YOUR-SITE>.atlassian.net/rest/servicedeskapi/organization/<organizationID>/user
Set the HTTP method to POST.
Add the “Custom data“ which will contain the reporter information. To get the reporter’s information, we will be using the smart values. “{{issue.reporter}}“ will return the reporter’s account ID.
{ "accountIds": ["{{issue.reporter}}"] }
Add Headers:
Key: Content-Type
Value: application/json
Add another header
Key: Authorization
Value: Basic <ADD THE ENCODED STRING>
Test Send Web Request action
Click on the Validate your web request configuration drop-down.
Enter an issue key and Validate the call.
You should see a green Response 204.
Click Payload to see the returned information.
Part 4: Finalize and validate all the steps
Putting together everything with the following steps, you’ll be creating the automation rule as shown below.
Add Trigger.
Add If block.
Add a positive “User condition” to the if block.
Add “Edit issue“ action to set the customer organization.
Add the Else block.
Add the negative “User condition” to the else block.
Add the “Send web request“ action based on the information mentioned above.
Add “Edit issue“ action to set the customer organization.
You can always Contact Atlassian support if you have any questions.
Related articles
Was this helpful?