Wokflow: Looping Data in Form Action Notification Body

Hi Team,

Is there a way in Workflow to loop through getAccounts in the form action notification body?

When I tried as below

#foreach( $account in {{$.getAccounts.accounts}} )
$account.sourceName
#end

this is giving an error while testing the workflow.

Thanks in advance !

I do it in this blog : Using IdentityNow Workflows to Send a List of Uncorrelated Accounts After Aggregation - Blog / Blog Posts - SailPoint Developer Community Forum

You can use :

	#foreach($account in $accounts)

And define variable in temp Templating Context :

"accounts.$": "$.hTTPRequest.body",

Hi @ondiaye ,

Thank you for your response !

However, I am looking for such implementation in Form Action under notification body, there we don’t have templating context or such.

As I tried it gives me error as below:

So, is there a way to loop in a form action.

Any further inputs will be helpful !

Regards

Hi @Aditya_Veldi,

I’m note sure but can you try this 2 example ?

#foreach($account in ${getAccounts.accounts}){

}
#end
#foreach($account in $.getAccounts.accounts){

}
#end

Hi @ondiaye ,

I tried both of them still the same issue.

The short answer is that velocity loops will not work with the Forms notification body.

Form notifications support velocity for primitive variables, like strings, numbers, and booleans. However, without the templating context that the Send Email action has, form notifications can’t handle arrays and objects. This is because inline variables are implemented in Golang, and they output arrays and objects using Golang notation. This means that arrays will look like this:

["item1" "item2"]

and objects will look like this:

map[id:ee769173319b41d19ccec6cea52f237b name:john.doe type:IDENTITY]

Velocity is built on Java and requires Java syntax for arrays and objects, which is not how inline variables are resolved. The reason you see a 400 error when attempting to setup a loop for an array is because it actually resolves to this in the code.

#set( $attributes=\"[\"department\" \"manager\" \"email\"]\")

This is not valid Java. For this to work, it would have to look like this:

#set( $attributes=["department","manager","email"])

The templating context in Send Email must be properly converting arrays and objects to the correct Java syntax, which is why the loop will work in Send Email.