Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
So I'm trying to make a call of our dataTable in an extension so I can then get an ID out of it and add it to an event message. But if I try to use GetDataTableEntries or FindDataTableEntry then it errors out of the try block. The errors are not helpful. I think I am instantiating my DataTableThing incorrectly and so when I reference any of its methods it fails, I haven't found how in the docs/api but just found examples like that.
The code is as follows:
try{
DataTableThing db = (DataTableThing) ThingUtilities.findThingDirect("myDataTable");
if(db != null)
log.info("Found the db");
InfoTable myInfoTable = db.GetDataTableEntries((double) 500)); //this also does not work if I pass null
log.info("Was able to get data table entries");
}catch(Exception e){
log.info("Couldn't get data Table entries");
}
I typed this out so if there are syntax issues feel free to ignore them.
What version of the extension developer are you using? I believe ThingUtilities is deprecated, but I can't find any documentation on it, so maybe not.
You may want to try using the EntityUtilities class:
DataTableThing myThing = (DataTableThing) EntityUtilities.findEntity("MyThing", ThingworxRelationshipTypes.Thing);
Can you debug and see if your call to find the entity is returning something? What do the errors say?
We are using Thingworx 6.0 just to clarify. I tried your solution and also I tried
DataTableThing db = (DataTableThing) ThingManager.getInstance().getEntity("myDataTableThing");
your solution returns null because it does not get past my error check. My attempts both return something, but still says unable to get entries: null so its a null object I assume.
I just hooked up the debugger and it finds it and I can see the description. But as I step through I get to where the datatable entries are showing in the variables in eclipse. Its strange because I'm seeing the current row is -1 and the size is 0. But if I look at the context it shows one row with all the fields filled as I'd expect.