This workaround is intended for people who would like that whenever an agent is added to the “Request participants” field, the user is removed automatically. When a customer adds an agent to their request as a participant, that agent is subsequently treated as a customer for the purposes of triggering SLAs, automation rules, or notifications. In most cases, this is not a desired scenario, so we will use this workaround to prevent this.
We will make use of Automation For Jira, Rest API, and Web Requests to accomplish this. I will explain the needed steps below:
Initially you will need an API Token created for authentication, to send a web request to an API endpoint using your automation rule. In case you don't have any API token configured, you may check the needed steps in this document.
Once created you won't be able to see it again, so I'd advise copying the API token string to another location, we will need this later.
With the above token created, you will need to encode it to the authorization string. In the 2nd step from this community post, there's a detailed guide on how to do so, but basically, we can make this through any online tool like Base64 encode or you can use a terminal session and execute the following:
$ echo -n "<email@example.com>:<YOUR_TOKEN_HERE>" | base64
You would need to replace <email@example.com> with your user’s email address and <YOUR_TOKEN_HERE> for the API token you generated at the previous step, separated by the “:” character and between the ““ characters. Once you execute this command, please save the generated string to use later.Go to your Project Settings > Automation and start a new rule using the following components:
We will use the "Field value changed" trigger.
In this case we will monitor changes in the “Request participants” field for “Value added” change type.
For the 2nd component, we will use an "Advanced branching" component, we will iterate on every user's account ID that are listed in the "Request participants" field.
We will use the following smart value.
{{Request participants.accountId}}
Inside the “Advanced branching” component we will use the “Send web request” action component. For every user in the “Request participants” field, we will get the groups that the user is a member. Here it gets a bit tricky, you will have to configure it with the following values:
Web request URL:
{{baseUrl}}/rest/api/2/user?accountId={{remove}}&expand=groups
You may find additional details for this API endpoint in this link.
Headers:
Accept: application/json
Authorization: Basic <base64-token>
Remember to replace <base64-token> by your generated base64 encoded string at the 1st step from this post.
HTTP Method:
GET
Web request body:
Empty
And Check the "Delay execution of subsequent rule actions until we've received a response for this web request" checkbox.
Once we have the response from the previous web request, we will use the an "Advanced condition" to check if the response contains a specific group.
In the “First value” we will use the following smart value:
{{webResponse.body.groups.items.name}}
For “Condition” we will use "contains".
In the “Second value” field, we will set any group name that we would like to identify our agents. In this example, I will use the group that provides default access to the JSM product ("jira-servicemanagement-users-<instance>"), but you may use any group that best suit your needs.
Finally, we will use the "Edit issue" action, to remove any user that matches the above condition (is a member of the group) from the "Request participants" field. For this, we will use the "More options" > "Additional fields" section from the action.
In the “Additional fields” section, we will use the following JSON:
{
"update": {
"Request participants" : [ {
"remove": {
"id":"{{remove}}"
}
}]
}
}
After setting up your automation rule, you should have something similar to this:
Rodrigo Henrique
3 comments