RPE DocSpec with multiple templates but only one variable input
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
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
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