# Iterate over trigger changes array in workflow

**URL:** <https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747>\
**Category:** SHF Discussion and Questions\
**Tags:** workflows, sailpoint-identity-security\
**Created:** [February 28, 2024, 8:00pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747 "2024-02-28T20:00:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dominick-miller](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/dominick-miller/32/29002_2.png) [@dominick-miller](https://developer.sailpoint.com/discuss/u/dominick-miller)\
**Post date:** [February 28, 2024, 8:00pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/1 "2024-02-28T20:00:07Z")

</div>

Hi,

I have a workflow that creates Jira tickets. Everything works perfectly, except when I output the $.trigger.changes into the Jira ticket, I receive one super long line that is not very easy to read. To solve this, I am trying to iterate over each change in the $.trigger.changes array and separate the changes by a new line character. I am currently stuck trying to add what should be relatively simple velocity logic (EX: #foreach($triggerChange in {{.$trigger.changes}}), but this does not work in the json formatted workflow.

Does anyone have experience with HTML formatting from within the IDN JSON workflow format, or with experience iterating over an array in JSON?

Thanks!

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [February 28, 2024, 9:42pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/2 "2024-02-28T21:42:03Z")

</div>

Can you share your workflow JSON with what you have tried so far, minus any sensitive data? That will give us a better idea of what your logic looks like so we can figure out a potential solution.

---

<div class="post-metadata">

**Author:** ![dominick-miller](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/dominick-miller/32/29002_2.png) [@dominick-miller](https://developer.sailpoint.com/discuss/u/dominick-miller)\
**Post date:** [February 28, 2024, 10:05pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/3 "2024-02-28T22:05:11Z")

</div>

Hi Colin,

My question is more general and not really workflow specific.

An example of what I’m trying to do is the following:

“text”: “#foreach($triggerChange in {{$.trigger.changes}})Attribute: $triggerChange.attribute, Old Value: $triggerChange.oldValue, New Value: $triggerChange.newValue\n”,

---

<div class="post-metadata">

**Author:** ![iamnithesh](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamnithesh/32/42445_2.png) [@iamnithesh](https://developer.sailpoint.com/discuss/u/iamnithesh)\
**Post date:** [February 28, 2024, 10:13pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/4 "2024-02-28T22:13:27Z")

</div>

> [@dominick-miller](#):
>
> “text”: “#foreach($triggerChange in {{$.trigger.c

You are trying velocity template element in a json. I don’t think this works

---

<div class="post-metadata">

**Author:** ![dominick-miller](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/dominick-miller/32/29002_2.png) [@dominick-miller](https://developer.sailpoint.com/discuss/u/dominick-miller)\
**Post date:** [February 28, 2024, 10:13pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/5 "2024-02-28T22:13:50Z")

</div>

I am aware. Is there an alternative to achieve the result I want?

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [February 28, 2024, 10:55pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/6 "2024-02-28T22:55:23Z")

</div>

I have not found a way with the native capabilities in workflows to do what you are asking. Workflows uses JSONpath as its JSON query language, which does not support the ability to insert values in between items in an array. The only JSONpath operator that comes close to this is the `concat()` operator, but you must specify each index in the array manually, which would not scale to your needs.

Workflow loops are asynchronous and unable to work on shared data, and the output of a loop is not available in later steps due to its async nature.

The define variable operator also does not appear to support this use case.

You will either have to output the whole string as you are now, or you will have to invoke an external service via the HTTP Request, like AWS Lambda, to do the processing for you.

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [February 28, 2024, 10:57pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/7 "2024-02-28T22:57:46Z")

</div>

In theory, you could use synchronous recursion in workflows to process your list of changes and append the new line after each change. If you’re interested, you could read up on it here:

> [@Recursive Workflows in IdentityNow](https://developer.sailpoint.com/discuss/t/recursive-workflows-in-identitynow/16235):
>
> IdentityNow Workflows provides a [loop operator](https://documentation.sailpoint.com/saas/help/workflows/workflow-operators.html#loop) that allows a workflow to process many items in a list of data in a quick and efficient manner. While the loop operator is a built-in component of Workflows, there is another way to achieve looping functionality using features that are currently supported in the product. In this blog, I will demonstrate how to implement recursion in Workflows to achieve looping behavior without the need for the loop operator. What is recursion? …

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [April 28, 2024, 10:57pm UTC](https://developer.sailpoint.com/discuss/t/iterate-over-trigger-changes-array-in-workflow/32747/8 "2024-04-28T22:57:50Z")

</div>

Closed on April 28, 2024, 10:57pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
