Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello all,
When I try to create "INTEGER" property using extension it throwing error as "Unable To Convert From java.lang.String to INTEGER"
Below is my code:
String propertyname = "TEST"; String type = "INTEGER"; JSONObject remoteBindingAspects = new JSONObject(); thingname.AddPropertyDefinition(propertyname, "", type, "", "", false, true, false, "VALUE", (double) 0, false, "", (int) 3, "VALUE", (double) 0, "", remoteBindingAspects);
Hi @Velkumar you need to ensure that you are working with ThingWorx BaseTypes, if you are looking to define a property of type Integer, it will be BaseTypes.INTEGER, e.g.
FieldDefinition Field1 = new FieldDefinition("Field1", BaseTypes.INTEGER);
Hello @supandey,
In our case datatype changes dynamically, how to overcome that.
Regards,
Velkumar R
Sorry i am not really sure what do you mean with datatype changes dynamically. If this is part of the infotable or datashape you can adapt that when creating them in runtime.
We are getting list of properties as Infotable with name and basetype.
For Example:
Name Basetype
P1 STRING
P2 INTEGER
We will iterate over this infotable and we will create property based on name and Basetype. We want to dynamically change the BaseType of property while creating.
So how we can change Basetype.STRING to Basetype.INTEGER based on Input ?
In scenario where you already know the BaseType as part of your input InfoTable, you can map that to the PropertyDefinition while create a new property.
If in case you do not get BaseType as input information you could look into using getClass()
Hope this helps.