Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hello all,
I'm trying to update Infotable property value using "UpdatePropertyValues" service. When I run the code, I'm getting error as "Unable To Convert From java.lang.String to INFOTABLE". Below is my code,
DataShapeDefinition updatepropertyShape = new new DataShapeDefinition();
updatepropertyShape.addFieldDefinition(new FieldDefinition("name",BaseTypes.STRING)); updatepropertyShape.addFieldDefinition(new FieldDefinition("time",BaseTypes.DATETIME)); updatepropertyShape.addFieldDefinition(new FieldDefinition("quality",BaseTypes.STRING)); updatepropertyShape.addFieldDefinition(new FieldDefinition("value",BaseTypes.STRING)); InfoTable updateproperty = new InfoTable(updatepropertyShape); Calendar currenttime = Calendar.getInstance(); JSONObject values = new JSONObject(); values.put("time", new DateTime(currenttime)); values.put("quality", "GOOD"); values.put("name", "MBT_CapacityOfMachine"); values.put("value", parsedValue); //ParsedValue is Infotable updateproperty.AddRow(values); thingName.UpdatePropertyValues(updateproperty);
I tried using "setPropertyValue" in service, I'm getting error as "com.thingworx.types.InfoTable cannot be cast to com.thingworx.types.primitives.IPrimitiveType"
thingName.setPropertyValue("Prope1", (IPrimitiveType<InfoTablePrimitive,InfoTable>) propertyValue);
Can any one help me to fix this issue ?
Regards,
VR
Solved! Go to Solution.
I don't know exactly on how do to it with Java extension, but on your code I can see some incongruences:
I don't know exactly on how do to it with Java extension, but on your code I can see some incongruences:
Hi @CarlesColl,
Thanks for your reply.
1. Double new is typo. It occurred while copying and pasting code in community.
2. When I convert infotable to String using "toString()" function it works fine.
Regards,
VR
Yes using toString you are converting the parsedInfotable to String again and your value it's of String and then it works as String but not as Infotable, what if you change the field definition for value to INFOTABLE ?
No, it working as INFOTABLE in extension. I just converted INFOTABLE to STRING and update my INFOTABLE property, it working fine.