Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello everyone, is there anyway to correctly pass a datashapeName as a parameter to a thingworx service? i've try to send a string, but after i execute the services it throws me an error about the dataShape being null.
Thank You for your time.
A string using double quotes "YourDataShape" usually works
I alreay tried that but no success.
I have tried this basic setup and it works for me:
A test service which creates a infotable from a datashape and has a string input test:
var params = {
infoTableName : "InfoTable",
dataShapeName : test
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(testDS)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
A test2 service which calls the test service:
var params = {
test: "testDS" /* STRING */
};
// result: INFOTABLE dataShape: "testDS"
var result = me.test(params);
And a datashape testDS with a few fields.
I get no issues with either of the services.
I hope this information helps you.
At the run time i get this warning.
There is a already a data type in ThingWorx called DATASHAPENAME. you can use this or simply use a string also; both has the same result except if you use DATASHAPENAME, you can search existing DataShapes from a dropdown when you run/ test the script.
Here is the steps:
1. Create a Service with a input. Called the Input Parameter Name as say "myDSName". (It can be either String or DATASHAPENAME). And set the service output as STRING.
2. Put the following snippet in the script window.
var result = DataShapes[myDSName].GetDescription();
3. When you run the script and pass an existing Data Shape Name (Description of the Data Shape name should not be empty) you will get the description of the Data Shape Name that you pass.
Note: Here you are running
GetDescription()
service to get the description. Similarly you can other script, create Data Table from the Data Shape etc.