Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
I have several small calculations that I would like to do. I can easily write a service for each of them and return an single value. I would like to have one service and just return a datatable of all of these values. Does anyone have an example on how to do this? I have found a few snippets of code, but I can't seem to get the syntax correct. Thanks!
P.S. Did the Correct Answer button disappear with the forum update? I don't see it anymore.
Solved! Go to Solution.
Create a DataShape with the fields that you want to return, let's name it MyShape, which has two fields: columnName1, columnName2.
Then create a new service which should look like:
var value1 = me.ServiceCalculation1();
var value2 = me.ServiceCalculation2();
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "MyShape"
});
result.AddRow({
columnName1: value1,
columnName2: value2
});
Of course the Return Value for this service should be InfoTable with DataShape: MyShape.
Create a DataShape with the fields that you want to return, let's name it MyShape, which has two fields: columnName1, columnName2.
Then create a new service which should look like:
var value1 = me.ServiceCalculation1();
var value2 = me.ServiceCalculation2();
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "MyShape"
});
result.AddRow({
columnName1: value1,
columnName2: value2
});
Of course the Return Value for this service should be InfoTable with DataShape: MyShape.
byutz - just wanted to confirm you were able to find the correct button. Let me know if you have any other questions about the ThingWorx Community upgrade over at the Community Hub.