How to Iterate through Artifacts in a DNG Module and Print out a Custom Attribute in RPE
How do we iterate through the artifacts in a module and print out the value of a specific custom attribute?
Attached is screenshot of a very simple template that should do this but it does not.
This template should iterate through the artifacts in a module, find the value of the custom attribute 'RPE Style' and then print it out.
I have a module which contains 3 artifacts (screenshot attached). The 3 artifacts have the values aaa bbb ccc for the attribute RPE Style.
When I run this template against my module with 3 artifacts I want it to print out
Style Variable is currently set to:- aaa
Style Variable is currently set to:- bbb
Style Variable is currently set to:- ccc
but instead it prints out
Style Variable is currently set to:- ccc
Style Variable is currently set to:- ccc
Style Variable is currently set to:- ccc
i.e. it prints out the last value 3 times
Screenshot of output also attached
Accepted answer
9 other answers
Comments
If you want to assign to variable, you should use an array or map to store the values. Else each time the variable value will be overwritten.
I am also curious to understand why my approach works when using a system variable like 'description' but it does not work when using a custom variable.
You can refer the screenshot of the simple template that should work for you:
Please note
1. You should print variable "style" within the query where variable assignment is done. If you are printing variable "style" outside the query, the last value assigned to the variable will be printed for each artifact.
2. The second query should be the child of first query. Else, for each requirement, "RPE Style" of all artifacts will be printed.