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 (1.3k241144) | asked Mar 06 '19, 2:33 p.m.
edited Mar 06 '19, 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

Accepted answer


permanent link
Subramanya Prasad Pilar (4.6k15) | answered Mar 08 '19, 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.
Sean F selected this answer as the correct answer

9 other answers



permanent link
Subramanya Prasad Pilar (4.6k15) | answered Mar 08 '19, 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 (1.3k241144) | answered Mar 08 '19, 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
Sean F (1.3k241144) | answered Mar 08 '19, 3:21 p.m.
edited Mar 08 '19, 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 (4.6k15) | answered Mar 12 '19, 2:17 p.m.
edited Mar 13 '19, 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 '19, 2:18 p.m.

This seems to work. Can you try it please?


permanent link
Sean F (1.3k241144) | answered Apr 07 '19, 11:02 a.m.
Hi Prasad,

Sorry I did not seem to get a notification that this question had been answered last month.

Yes, I can print it out OK using a condition but when I try to assign the value of the attribute to a variable it does not seem to work.

Assigning to a variable is specifically what I am trying to achieve, not printing out. Sorry, the OP is worded inaccurately.

It works fine when I assign the value of a system variable, such as 'description', but if I instead try to assign the value of a custom variable it does not work.

Comments
Subramanya Prasad Pilar commented Apr 07 '19, 1:00 p.m.

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.


Sean F commented Apr 08 '19, 8:19 a.m.
Thanks Prasad.

I have searched for map and array in the RPE help but I cannot find these items.

Do you have a link to these features in the documentation?

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.

permanent link
Sean F (1.3k241144) | answered Apr 07 '19, 11:06 a.m.
I cannot upload templates to the forum but the templates are available in the case notes for IBM technical support case ID TS001941498


permanent link
Sean F (1.3k241144) | answered Apr 08 '19, 8:21 a.m.
Thanks Prasad. (I cannot reply to your comment - for some reason the 'post comment' button does not work but the 'post reply' button works in Firefox)

I have searched for map and array in the RPE help but I cannot find these items.

Do you have a link to these features in the documentation?

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.


permanent link
Sean F (1.3k241144) | answered Apr 08 '19, 12:41 p.m.
edited Apr 08 '19, 12:42 p.m.
Thanks for the link Prasad.

I will have a look through and see how it might be possible to use Arrays to solve this.

What I am trying to do seems like a common thing for users to want to do.

Just like we used to do in DOORS Classic we want to use a string attribute to store the name of the 'style' to be used in the stylesheet when publishing that artifact.

That used to be simple to achieve in RPE with DOORS classic using a custom attribute or a system attribute. It is also simple to achieve in DNG but only when using a system attribute.

I would like to understand the reason why my template works when using the system attribute 'description' but it does not work when using a custom attribute 'RPE Style.

Can you tell me the reason why my assigning the value to the variable is not working in the latter case?

Is storing a 'style' value in an attribute for use when publishing with RPE not a common thing that users wish to achieve and so has it not been solved previously?

permanent link
Subramanya Prasad Pilar (4.6k15) | answered May 15 '19, 3:03 a.m.

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.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.