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?
|
Accepted answer
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
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
|
^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.
|
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:-
DTA Template:-
Word 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.
|
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?
|
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.
|
I cannot upload templates to the forum but the templates are available in the case notes for IBM technical support case ID TS001941498
|
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. |
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?
|
You can refer the screenshot of the simple template that should work for you:
|
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.