About flow variables
- Flow variables can be passed as URL parameters or URL variables to the user-created API endpoints.
- Flow variables can be passed as URL parameters to the run flow by name API.
- Flow variables can also be defined when creating nested flows.
How to convert
If the flow variables are defined when creating nested flows
Step 1. Create JavaScript flow.
Step 2. Add the following JavaScript code:
importPackage(com.toolsverse.config);
var vars = scenario.getVariables();
var props = 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 = SystemConfig.instance().getProperties();
on
var props = SystemConfig.instance().getContextProperties();
Step 3. Add JavaScript flow to the nested flow as a step 1.
If the flow variables are passed from the API
Step 1. Add the flow which receives an API request to the nested flow as a step 1.
Step 2. Add the following conditions to step 1:
importPackage(com.toolsverse.config);
var vars = scenario.getVariables();
var props = 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 = SystemConfig.instance().getProperties();
on
var props = SystemConfig.instance().getContextProperties();
Comments
0 comments
Please sign in to leave a comment.