Combine multiple artifacts in a loop after a join

I have a workflow ,that uses a teams trigger, that uses a loop that has 3 discission branches and at the end of each branch I have an artifact that is used to create a message that would be included in the final output of the workflow. I would like to combine any of the artifacts at the end any branch that is followed to one or more variables that could then be used to report back the results to user in Teams the final statuses. For example, the message could be

The following tickets were opened:
<plugin id>:<ticket number>
<additional lines per ticket created>

The following plugins failed to have tickets created:
<plug-in id>
<additional lines per failed item>

The following plug-ins were not found:
<plug-in id>
<additional lines per unknown plug-in ids>

I have a join to join all of the branches together to a single point at the end of the loop and configured to use the variables/artifacts at the end of each branch.

The artifacts in the red boxes below are what are used for the join variable:

2024-07-10_workflow_join

The join configuration is the following:

2024-07-10_join_config

Since I want to send the message outside of the loop, I know I need to configure the loop output for each result. However, I am stuck as to how to get each of the results added to separate arrays to be used as the loop outputs. I figured I might need to use another decision after the join, but I no idea what do after that. I thought about using a global artifact but I am pretty sure that is the wrong approach.

Any direction that can be provided would be greatly appreciated, even if it is a link to documentation I am not seeing.

Thanks,
Sean

Hey bud - Since you’re using a join step, no matter what the result of the path selection ends up being, it’ll result in your join variable: “join_ticket_creation_msg” containing the string in question.

You only have to include it in a loop output as an array (since there’s no string), but once you do, and unpack it aka:
[Loop_output_array].[0]
(.[0] for the first item in the array / in your case ONLY item in the array)

it should reference the same join variable!

hope this helps! Sorry for the delay, but I don’t work here anymore unfortunately!

First, since you are looking to pass artifacts out of the loop through the join, I would change the data type to a string since artifact contents are strings. Secondly this join gives you a single variable called join_ticket_creation_message with one artifact from the decision step so I’m not sure what you are trying to accomplish with multiple loop outputs. If you are trying to pass another variable to the loop output to say what decision was made you could always add a second join variable and hardcode a string for each path and then pass it as a second loop output.

Hey no problem and thanks for the information! I actually went a different route. I add the contents of the artifact to an output variable for the loop and use is_defined(artifact.content). And outside of the loop I am using handlebars if statements and loops in an artifact to create the final message before sending it back to the user via teams.

Thanks for the information! I will keep it in mind the next time I need to do something like this. I ended up just adding each message to different output arrays and using is_defined(). Outside of the loop I am using handlebars to expand the different variables if they contain data.