Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a comment to Issue Lookup result within FOR EACH Branch

Abdul Mohammad
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 15, 2024

I am using a webhook as my trigger which comes from our HR management platform when a monitored field on that platform is changed for an employee.

E.g if an employee's location is changed, it triggers a POST to the webhook which creates a ticket in Jira. The problem is that multiple fields are monitored, and if the same employee undergoes multiple field changes, then multiple tickets are made.

I want to use a JQL to search for tickets using the employee ID as a webhook smart value so that instead of creating a new ticket each time, I first look for an existing ticket and add a comment to that.

This is all relatively simple, as I can use a JQL search with an Issue Lookup. The problem is that the HR platform will POST a JSON with multiple employees occasionally. This is because the shortest trigger time I can set is 60 seconds, and if multiple employees undergo a change within those 60 seconds they all get added to one JSON.

To combat this i use a FOR EACH loop on every employee ID in the JSON. However, after performing an issue lookup within this for each loop, I have no way to reference any of the resulting issues from the lookup so that I may add a comment (no way to add nested loops as of now).

Does anyone know how I can reference the resulting list of issues from an issue look up within a FOR EACH loop?

Note: I can't use the JQL search within the webhook trigger because I use the employee ID smart value from the FOR EACH loop within my query.

Screenshot 2024-11-15 163358.png

2 answers

1 accepted

1 vote
Answer accepted
Tomislav Tobijas
Community Champion
November 16, 2024

Hi @Abdul Mohammad ,

Regarding this:

To combat this i use a FOR EACH loop on every employee ID in the JSON. However, after performing an issue lookup within this for each loop, I have no way to reference any of the resulting issues from the lookup so that I may add a comment (no way to add nested loops as of now).

You kinda can get this by doing the following:

  1. On the first level of automation, create a branch but do NOT select which branch type (Advanced branching, Branch on AQL, Branch rule).
  2. Then drag & drop this component under the existing branch.
  3. Once that's done, select which branch type you want.
  4. Viola! (note that this is not yet officially supported, but it works; we use it for up to three levels of branching/branch inside a branch)

nested-branching.png

So with that, you could first check employees (as you do now) and then create another loop inside of that for each issue which contains the ID for the current (looped) employee.

Hope this helps.

Cheers,
Tom

0 votes
Kristján Geir Mathiesen
Community Champion
November 15, 2024

Hi @Abdul Mohammad 

I haven't tried this but maybe you can load a variable and then use it in the branch, like:

SCR-20241115-nopg.png

HTH,
KGM

Abdul Mohammad
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 15, 2024

Hi @Kristján Geir Mathiesen thanks for your suggestion. I have used this feature to reference each of the employee ID's within the automation.

Problem arises when I try to add a comment to an issue that includes the employee ID. I have no way to reference the issue specifically in the automation.

Kristján Geir Mathiesen
Community Champion
November 18, 2024

Sorry to hear, @Abdul Mohammad  I haven't looked deep into this. Was just hoping to prod you in the right direction :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events