Can you make sure that 'guids' is an array?
var guids = [];
guids.push(guid);
This our workaround
function generateConstraintsFromArray(guids: string[]) {
var result;
result = "[";
for (var i = 0; i < guids.length; i++) {
if (i === 0) {
result += "id=" + guids[i];
}
else {
result += "or id=" + guids[i];
}
}
result += "]";
return result;
}
async function mxAction(microflow: string, guids: string[], entityType?: string): Promise<any | undefined> {
return new Promise(resolve => {
var params;
if (!entityType) {//normal case
params = {
applyto: "selection",
guids: guids
};
} else {
if (guids.length === 1) {//workaround
params = {
applyto: "selectionset",
sort: [["id", "asc"]],
xpath: "//" + entityType,
constraints: generateConstraintsFromArray(guids)
};
} else {
params = {
applyto: "selection",
guids: guids
};
}
}
mx.ui.action(microflow, {
context: new mendix.lib.MxContext(),
params: params,
progress: "modal",
callback: function (objs: any) {
resolve(objs);
},
error: function (error: any) {
resolve(undefined);
if (error.message) {
mx.ui.error(error.message);
}
}
});
});
}