It's all about the answers!

Ask a question

How to Iterate through Artifacts in a DNG Module and Print out a Custom Attribute in RPE


Sean F (30912129) | asked Mar 06, 2:33 p.m.
edited Mar 06, 2:41 p.m.

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


RPE Module

The Template

Word Output

5 answers



permanent link
Subramanya Prasad Pilar (3.1k13) | answered Mar 08, 4:50 a.m.
Hi Sean,
You should insert the Paragraph element (that prints style variable) within the query ($31). With the template you provided, variable "style" has the latest value assigned ("ccc") and hence same is printed for all 3 artifacts.

Regards,
Prasad

permanent link
Sean F (30912129) | answered Mar 08, 6:53 a.m.
^Thanks Prasad

Sorry the question has been stated in an oversimplified manner.

I am actually trying to extract the custom attribute value into a variable so I can do something with it later in that loop within the module iteration for each artifact.

This is a simplified example of the problem where I just print out the value of the variable.

I have been able to simply print out the attribute value by doing it inside the $31 query but what I really want to do is assign the attribute value to a variable and then use the variable later in the $10 loop.

The thing I am actually trying do is use the Variable to set the Style property of the paragraph when printing each artifact in the module.

permanent link
Subramanya Prasad Pilar (3.1k13) | answered Mar 08, 7:11 a.m.
Did you try storing the requirement IDs and values of custom attribute in a map? You can later iterate through the map and print the custom value corresponding to the requirement.

permanent link
Sean F (30912129) | answered Mar 08, 3:21 p.m.
edited Mar 08, 3:24 p.m.
Hi Prasad.

Here are screenshots of doing exactly the same thing but using the Description attribute.

The assignment to the Variable and the artifact iteration works fine when I use the Description attribute.

It does not work when I try to do it with a custom attribute.

Data:-
Module
DTA Template:-

DTA

Word Output:-
Output

What is even stranger is that I had this working in an older version of RPE 2.1.1

In 6.0.6 it is not working.

permanent link
Subramanya Prasad Pilar (3.1k13) | answered Mar 12, 2:17 p.m.
edited Mar 13, 5:27 a.m.
You can get this without using any variable or map. Just use a condition (name == "RPE Style") on the query dataSource/artifact/collaboration/attributes/objectType/customAttribute as in the screenshot.

Comments
Subramanya Prasad Pilar commented Mar 12, 2:18 p.m.

This seems to work. Can you try it please?

Your answer


Register or to post your answer.