It's all about the answers!

Ask a question

RPE DocSpec with multiple templates but only one variable input


Michael Toole (31168) | asked Oct 01 '14, 1:53 p.m.
 I have a RPE docspec with about 10 templates.  Those templates all have the same variable that i want to apply to.   

I have a popup that will ask me for the variable input and that works but i have to do it on all ten templates on generation.  

How can i put in the variable once on the first template generation and it populate throughout all the others?

2 answers



permanent link
Subramanya Prasad Pilar (4.6k16) | answered Oct 01 '14, 3:16 p.m.
I am afraid you cannot do that. You can rather use a central library variable in all 10 templates. The value set to the central library variable will be used in all templates.

Comments
Subramanya Prasad Pilar commented Oct 01 '14, 3:18 p.m.

Another option is to dynamically import a template (which uses the external variable) in all 10 templates.


permanent link
Kumaraswamy Gowda (39115) | answered Oct 06 '14, 4:47 a.m.
Hi Michael,

As Prasad mentioned, there is no straight forward solution.

The central library solution might not help if you want to change the value of the variable in the template and it should be seen in the other template.

How about this solution? The solution is to store the reusable variable in Java System Property. See attached templates and doc spec.

- Template 1 uses ext_var1 variable. The values is incremented upto 5. The value is also store in Java System Property.
- Template 2 reads the value from the same Java System Property and stores it in it's own variable ext_var1 and print values again.

I don't see a way to share artifacts here. Hence pasting a simple javascript code to achieve it.

1. Create a variable (say ext_var1) in template 1.
2. Assign ext_var1 with some value and set it in system property.
3. Use the same system property value in other template directly or set it to a variable and use it.

ext_var1 *= 1;
java.lang.System.setProperty("reuse_some_variable", ext_var1 + "");
ext_var1 = java.lang.System.getProperty("reuse_some_variable") * 1;

Note: The property value "reuse_some_variable" will be available for that particular RPE session. Hence make sure to reset it (to blank). Concurrent document generation using the same system property name could result in undesired behavior as other document generation could override the property value.

Thanks,
Kumar

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.