Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate the entire conversation x

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

bnagilla
1-Visitor

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
12-Amethyst
(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.

Announcements
Top Tags