Overview
When the flow variables are set using one of the following methods:
- Flow variables defined when creating nested Flows.
- Flow variables set and accessed programmatically
they can be programmatically converted to global variables.
Process
How to convert if the Flow variables are defined when creating nested Flows
Here are the steps you can follow:
Step 1. Create JavaScript Flow.
Step 2. Add the following JavaScript code:
var vars = scenario.getVariables();
var props = com.toolsverse.config.SystemConfig.instance().getProperties();
if (vars != null && !vars.isEmpty()) {
for (var i = 0; i < vars.size(); i++) {
props.put(vars.get(i).getName(), vars.get(i).getValue());
}
}
If you expect the global variables to be used in the loop with enabled multithreading, replace the line:
var props = com.toolsverse.config.SystemConfig.instance().getProperties();
on
var props = com.toolsverse.config.SystemConfig.instance().getContextProperties();
Step 3. Add JavaScript Flow to the nested Flow created in step 1.
How to convert if the Flow variables are passed from the API
Here are the steps you can follow:
Step 1. Add the Flow which receives an API request to the nested Flow as step 1.
Step 2. Add the following conditions to step 1:
var vars = scenario.getVariables();
var props = com.toolsverse.config.SystemConfig.instance().getProperties();
if (vars != null && !vars.isEmpty()) {
for (var i = 0; i < vars.size(); i++) {
props.put(vars.get(i).getName(), vars.get(i).getValue());
}
}
value = true;
If you expect the global variables to be used in the loop with enabled multithreading, replace the line:
var props = com.toolsverse.config.SystemConfig.instance().getProperties();
on
var props = com.toolsverse.config.SystemConfig.instance().getContextProperties();
Comments
0 comments
Please sign in to leave a comment.