OK, that seems really strange that it is possible to do via EXECUTE AUTOMATION COMMAND and it is also possible with the buttons insider a Ticket Lister widget.
@emre Are you planning to implement multiple command values for Automation Command Button widgets in the future?
It will allow me to have a series of buttons on an entity screen all triggering just one rule. Then within that rule a bunch of logic can happen using several variables. For example I can setup a bank of buttons to set “fresh” or “not fresh” for a bunch of different things like apples, bananas and oranges… This would be a total of 6 buttons each two different hard coded variables. This way the user can click any of these buttons to immediately set the state of a particular thing.
No… This series of buttons is setting custom data values for specific entities.
Because each button is set-up on an entity screen to do a specific thing (setting a specific value in a specific entity)… The text displayed on each button is different, and that corresponds to the values that are going to be changed.
@mjb2000 you posts last month got me thinking when I came to a similar scenario 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.
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.
Using the above you could pass your Entity=MyName,EquipType=BCD as {CALL:commandValue.newValues('Entity=MyName,EquipType=BCD')}
Then in your rule you can call values back out of the JSON string using the getValue function ie; {CALL:commandValue.getValue('[:CommandValue]','Entity')} and {CALL:commandValue.getValue('[:CommandValue]','EquipType')}
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.
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 but should be able to use most system variables available.