Step | Details | Output value | Note |
|---|
1 | Lookup issues by this JQL: project = ITSM AND "Approvals[Approvals]" = pending() To restrict testing to certain users, we can append a JQL query with their specific user IDs: AND ("Approvals[Approvals]" = pendingBy("61dfe44b7c6f980070c2d25a")
OR "Approvals[Approvals]" = pendingBy("608ac7795426330072fca171")) | {{lookupIssues}}: The list of issues that have pending approval:
 | |
2 | Create a variable to store all Approvers by using this smart value:
 {{lookupIssues.Approvers.emailAddress.distinct}}
| {{listApproverEmails}}: the list of Approvers: [phong@abc.com], [baoduy@abc.com], [baoduy@abc.com, phong@abc.com] (It’s a list of multiple arrays). | The distinct function only remove duplicate array, not items in the array. |
3 | Create the same variable and remove the [, ] and space characters: {{listApproverEmails.replace("[", "").replace("]", "").replace(" ", "")}}

| {{listApproverEmails}}: the list of Approvers without array: phong@abc.com,baoduy@abc.com,baoduy@abc.com,phong@abc.com
The purpose of each function: .replace("[", ""): To remove the [ character. .replace("]", ""): To remove the ] character. .replace(" ", ""): To remove the space character.
| |
4 | Loop through the Approvers with values that have been distinct: {{listApproverEmails.split(",").distinct}}

| {{listApproverEmails}}: the list of Approvers with distinct values: phong@abc.com, baoduy@abc.com {{approverEmail}}: The variable to store the loop item.
| The .split(",") function did the trick to convert a string with , characters to a list to loop. |
5 | Lookup issues to get the pending approval issues of each Approver in the loop: "Approvals[Approvals]" = pendingBy("{{approverEmail}}") AND project = ITSM

| {{lookupIssues}}: The list pending approval issues of each Approver. | |
6 | Condition logic to check if the previous lookup actions is NOT empty:
 | Continue the rule if it passes the condition. | |
7 | Send Slack messages to the target username (NOT channel) by sending the webhook to the configured Slack Incoming WebHooks with a customized channel field from the JSON body: {
"text": "Hi there, there are {{lookupIssues.size}} pending request(s) that require your approval:<br> {{#lookupIssues}} \n * Click here (<https://YOUR-SITE.atlassian.net/servicedesk/customer/portal/6/{{key}}|{{key}}: {{summary}}>) <br>to approve this request for {{reporter.displayName}} \n {{/}}",
"channel": "@{{approverEmail.split("@").get(0)}}"
}More details to set up the Slack incoming webhooks: https://api.slack.com/legacy/custom-integrations/messaging/webhooks and formatting text: https://api.slack.com/reference/surfaces/formatting | Each Approver will receive Slack messages by Slackbot about their pending approval issues:
 | |