I’m attempting to run a task in a workflow where I send an email with certain information collected in a Javascript step that runs before it. It’s important to note that the Javascript step result returns a number of Javascript structs with variables in them. Since I want to send an email for each of these structs, I am using the looping option in the Task. The looping variable in this case is called “teams” (referenced as {{ _.teams }}).
It seems that for the most part when it comes to pulling values from this struct in the “Subject” and “To” fields, referencing this variable works just fine. However, I am using a Jinja for-loop in the content and am running into issues.
It’s important to note here that within each struct/item I’m looping through is a list of structs, with each struct containing further information. This list of structs is called “resourcesToCorrect”, and I’m referencing it in the content as {{ _.teams.resourcesToCorrect }}. Printing out the struct in the content works just fine and returns the data, but because I’m not doing any formatting, it’s unreadable. Hence why I’m wanting to loop through this list, so that I can format the information in a way that is easy to read by the receiver.
This is where I’m running into issues. I’m using the Expression Reference document to set up a for-loop in this case. Based on the documentation, it seems like I should be setting up my loop like so:
{% for resource in {{ _.teams.resourcesToCorrect }} %}
- {{ resource.name }}
{% endfor %}
Unfortunately, when I try to run this step, I get the following error:
“Error evaluating ‘content’ in input. expected token ‘:’, got ‘}’
Use the expression preview in edit mode to review the input.”
I’m not sure why it’s expecting “:”, as this is not suggested in either the Dynatrace or Jinja documentation. With that said, I realize Dynatrace does not have examples for using a loop item in a Jinja for-loop.
What have I done wrong here?
