cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Error: Unable To Convert From java.lang.String to INTEGER

Velkumar
19-Tanzanite

Error: Unable To Convert From java.lang.String to INTEGER

 

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);
5 REPLIES 5
supandey
19-Tanzanite
(To:Velkumar)

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);

Velkumar
19-Tanzanite
(To:supandey)

Hello @supandey,

 

In our case datatype changes dynamically, how to overcome that.

 

Regards,

Velkumar R

supandey
19-Tanzanite
(To:Velkumar)

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.

Velkumar
19-Tanzanite
(To:supandey)

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 ?

 

supandey
19-Tanzanite
(To:Velkumar)

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.

Announcements


Top Tags