Hello,
I am going to try and be as descriptive as possible here and full disclosure I am new to using the template language. I am working with some of the limitations of JSM and approval groups. We need to achieve 2 things: Send an email reminder to pending approvers; Add a comment stating the status of each groups approval. The overall goal is to understand which group has approved and which group is still pending since JSM does not show this status in the JSM portal.
Challenges for first scenario
When groups are designated as approvers, every member of those groups are individually listed on the API side, without any association to their respective groups. When one member fulfills the approval requirement for their group, the approval status of the other members remains marked as pending. The entire approval step is linked to both groups; therefore, even if one member has approved (we have configured it so that only one approval is necessary from each group), the finalDecision flag continues to indicate pending. Consequently, when utilizing the Pending Approvers group to send email reminders, all users receive the email, regardless of whether their group approval has been fulfilled.
API example:
id": "XXX",
"name": "Name of your Approval Step",
"finalDecision": "pending",
"canAnswerApproval": false,
"approvers":
[{"approver":
{"accountId": "useraccountid ",
"emailAddress": "useremailaddress ",
"displayName": "userdisplayname "
"active": true,
"approverDecision": "approved"
My workaround
Apparently, you can use smartvalues in the Send Email To field and so I've tried this which is kind of working but it's not looping through all of the users for some reason
Create Variable
VariableName: pendingApproverEmails
Smart value: {{#issue.Approvals}}{{#if(equals(name, "Name of approval step"))}}{{#approvers}}{{#if(equals(approverDecision, "pending"))}}{{approver.emailAddress}},{{/}}{{/}}{{/}}{{/}}
The output is this: ,username@ourdomain.com,,
There should be 3 users it finds and sends the email to in this test case
(Update: Actually this won't work and just presents the same problem. All users with a 'pending' status will receive the email even if someone from their group has already provided the approval.)
Challenges for second scenario
The second scenario, I think I am just having issues with the template logic.
I keep getting "Closing tag (if) does not match opening tag error."
I am open to other suggestions on how to achieve this so please feel free to add your thoughts on that as well.
Thank you!