Hi all!
I’m working with UiPath Apps and wonder if there is a way to set data values to an app variable of type datatable, from the javascript part in a Custom HTML object?
For string variables you can for example do the following which will update the app variable varStrData with the test string:
async function setAppData() {
try {
var testvarvalue = 'test data string...';
await App.setVariable('varStrData', testvarvalue);
} catch (e) {
console.log("Error:", e);
}
}
I tried to set a datatable variable with this example but got the error message below:
async function setAppData() {
try {
var testvarvalue = "[{column_1: 'tesdata_1_1', column_2: 'testdata_1_2'},{column_1:'tesdata_2_1',column_2:'testdata_2_2'}]";
await App.setVariable('varDtDisplayData', testvarvalue);
} catch (e) {
console.log("Error:", e);
}
}
Error message:
Unexpected JSON token when reading DataTable. Expected StartArray, got String. Path '', line 1, position 141.
It seems like it want a datatable object or array but it says it got a string.
Maybe I need to convert the JSON-string to an object? But how?
I have searched the forum and webb without luck. And tried different examples.
Best wishes,
Benny