Although probably not a common scenario, I hit a case where I needed to pass several values through an execute automation command and I have come up with an alternate solution available now using scripts to pass multiple variables as JSON.
I adopted this approach over using program settings as like the ‘on the fly’ flow plus some scenarios may not allow for it.
function newValues(input) {
var input =input.toString();
var jsonArray = {};
var splitParams = input.split(',');
for (var p = 0; p < splitParams.length; p++) {
var singleParam = splitParams[p];
var splitSingleParam = singleParam.split('=');
var paramName = splitSingleParam[0].toString();
var paramValue = splitSingleParam[1].toString();
jsonArray[paramName] = paramValue;
}
return JSON.stringify(jsonArray);
}
function getValue(input,getValue){
var jsonArray = JSON.parse(input);
return jsonArray[getValue]
}
function addValues(input,newValues){
if(input){
var jsonArray = JSON.parse(input);
}else{
var jsonArray = {};
}
var splitParams = newValues.split(',');
for (var p = 0; p < splitParams.length; p++) {
var singleParam = splitParams[p];
var splitSingleParam = singleParam.split('=');
var paramName = splitSingleParam[0].toString();
var paramValue = splitSingleParam[1].toString();
jsonArray[paramName] = paramValue;
}
return JSON.stringify(jsonArray);
}
You would then place multiple values in the command value field using a CALL which will render as a JSON string for parsing in the rule later.
The scripts could probably do with some refinement and verification and you would need to be careful with special characters including quotes, double quotes, comma, colons and curly brackets which would interfere with JSON format. Be sure to test using show message or ask question to display values and check they are as expected.
Values should be entered as a comma separated list of name=value ie;
'<name1>=<value1>,<name2>=<value2>,<name3>=<value3>'
There is no limit to the number of name=value pairs.
In my example I used [?Prompt] for values to be entered for testing but you should be able to use most system variables available to the rule event or scenario used.
Calling values needs the JSON sting in [:CommandValue] input first followed by the name for the value you wish to call ie;
'[:CommandValue]','<name1>'