Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello, I have a problem to solve this : I have an Infotable create in Thingworx and I want to use Java Edge SDK in order to enter data in the first row.
Today, I got this :
ValueCollection row = com.thingworx.crypto.functions.HTTPRequest(pictureFolder, urlHTTP, predictionKey);
FieldDefinitionCollection fields = new FieldDefinitionCollection();
fields.addFieldDefinition(new FieldDefinition(NAME, BaseTypes.STRING));
fields.addFieldDefinition(new FieldDefinition(DATE, BaseTypes.DATETIME));
fields.addFieldDefinition(new FieldDefinition(C, BaseTypes.STRING));
fields.addFieldDefinition(new FieldDefinition(Z, BaseTypes.STRING));
defineDataShapeDefinition("ds", fields);
InfoTable resultInfoTable = new InfoTable(getDataShapeDefinition("ds"));
ValueCollection entry = new ValueCollection();
entry.clear();
entry.SetStringValue(NAME, row.getValue(NAME));
entry.SetDateTimeValue(DATE, row.getValue(DATE));
entry.SetStringValue(C, row.getValue(C));
entry.SetStringValue(Z, row.getValue(Z));
resultInfoTable.addRow(entry.clone());
It seems to work because there is the right datas into resultInfoTable but i cant push the row in my InfoTable property in thingworx, i tried invokeService and writeProperty but didn't work too. I'm really stuck so if somebody know how I can do this it'd be very nice !
Solved! Go to Solution.
I found the solution to do this, I'm gonna write it here for those which are stucked like me, by the way, I modified my code to make it more simple. Indeed, I already tried writeProperty but I guess I did something wrong the last time, but today it work. Here is the solution :
EDIT : into the function in the first line, i got the ValueCollection with all datas I need.
ValueCollection row = com.thingworx.crypto.functions.HTTPRequest(pictureFolder, urlHTTP, predictionKey); // Take the row into row (ValueCollection)
FieldDefinitionCollection fields = new FieldDefinitionCollection(); // Create fields for the infotable
fields.addFieldDefinition(new FieldDefinition(NAME, BaseTypes.STRING)); //Name field
fields.addFieldDefinition(new FieldDefinition(DATE, BaseTypes.DATETIME)); //Date field
fields.addFieldDefinition(new FieldDefinition(C, BaseTypes.STRING)); //C field
fields.addFieldDefinition(new FieldDefinition(Z, BaseTypes.STRING)); //Z field
defineDataShapeDefinition("ds", fields); // Defining dataShape name with its fields
InfoTable resultInfoTable = new InfoTable(getDataShapeDefinition("ds")); // Create the infoTable with the datashape create previously
resultInfoTable.addRow(row.clone()); //add row into the infotable
getClient().writeProperty(ThingworxEntityTypes.Things, getName(), "processedImage", new InfoTablePrimitive(resultInfoTable), 10000); // modify the infotable in thingworx
/// write Property --> Things, NAME_OF_THE_THING, NAME_OF_THE_PROPERTY, PRIMITIVE_INFOTABLE(INFOTABLE), 10000
Thanks, good bye !
I found the solution to do this, I'm gonna write it here for those which are stucked like me, by the way, I modified my code to make it more simple. Indeed, I already tried writeProperty but I guess I did something wrong the last time, but today it work. Here is the solution :
EDIT : into the function in the first line, i got the ValueCollection with all datas I need.
ValueCollection row = com.thingworx.crypto.functions.HTTPRequest(pictureFolder, urlHTTP, predictionKey); // Take the row into row (ValueCollection)
FieldDefinitionCollection fields = new FieldDefinitionCollection(); // Create fields for the infotable
fields.addFieldDefinition(new FieldDefinition(NAME, BaseTypes.STRING)); //Name field
fields.addFieldDefinition(new FieldDefinition(DATE, BaseTypes.DATETIME)); //Date field
fields.addFieldDefinition(new FieldDefinition(C, BaseTypes.STRING)); //C field
fields.addFieldDefinition(new FieldDefinition(Z, BaseTypes.STRING)); //Z field
defineDataShapeDefinition("ds", fields); // Defining dataShape name with its fields
InfoTable resultInfoTable = new InfoTable(getDataShapeDefinition("ds")); // Create the infoTable with the datashape create previously
resultInfoTable.addRow(row.clone()); //add row into the infotable
getClient().writeProperty(ThingworxEntityTypes.Things, getName(), "processedImage", new InfoTablePrimitive(resultInfoTable), 10000); // modify the infotable in thingworx
/// write Property --> Things, NAME_OF_THE_THING, NAME_OF_THE_PROPERTY, PRIMITIVE_INFOTABLE(INFOTABLE), 10000
Thanks, good bye !