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

i am creating thing through service but values are not getting populated

bnagilla
1-Newbie

i am creating thing through service but values are not getting populated

i have created a mashup and i mashup  for adding a thing. I have created a service to auto create a thing but values are not getting set into properties. Can anyone please help me out to resolve this.

var params = {

  name: Name /* STRING */,

  description: Description /* STRING */,

  thingTemplateName:"productthingtemplate" /* THINGTEMPLATENAME */,

  tags: undefined /* TAGS */,

};

// no return

Result=Resources["EntityServices"].CreateThing(params);

var params = {

  values: undefined /* INFOTABLE */

};

// no return

Things["proservice"].SetPropertyValues(params);

Things[Name].Name = Name;

Things[Name].Companyname = Companyname;

Things[Name].Description = Description;

Things[Name].MRP = MRP;

Things[Name].Manufacturingdate = Manufacturingdate;

Things[Name].Expirydate = Expirydate;

This is the code i am writing in sevice,

    Thanks in advance,

2 REPLIES 2
posipova
20-Turquoise
(To:bnagilla)

Hi,

You have to have a datashape assigned to your infotable input for the values. In the following example, I already have a thing created with a couple of properties. I ran the service "GetPropertyValues" and created the datashape from the executed result. Then I created a service to populate the values, with the infotable input assigned to the datashape.

So in your case, you need to first define new properties on the thing you created via your script (by using AddPropertyDefinition), then create a datashape before populating the properties.

ankigupta
5-Regular Member
(To:bnagilla)

Hi bhargavi nagilla​, You should rather use UpdatePropertyValues service to update property values.

Also, following code seems unrelated to your requirement:

var params = {

  values: undefined /* INFOTABLE */

};

 

// no return

Things["proservice"].SetPropertyValues(params);

If you are using some Remote Thing then you should use restartThing service after Creation to make sure Thing is running.

I hope it helps.