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

UpdatePropertyValues service

fblondy
7-Bedrock

UpdatePropertyValues service

Hi there

I've tried everything I could think of but I could not correctly call the UpdatePropertyValues function.

What Infotable is it waiting for ?

I need it for updating logged properties simultaneously, to not create a new log for each one.

if you have another solution for this problem, i'll gladly hear it, but I'd like an answer to the question because it has been bothering me for months.

Thank you.

ACCEPTED SOLUTION

Accepted Solutions
qn
12-Amethyst
12-Amethyst
(To:fblondy)

Hi,

Here is how I use this service:

var params = {

      infoTableName: "UpdatePropertiesInfoTableTMP" /* STRING */,

      dataShapeName: "NamedVTQ" /* DATASHAPENAME */

};

var updateValues = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var time = new Date();

updateValues.AddRow({'time': time, 'name': 'Property1Name', 'quality': 'GOOD', 'value': property1Value});

updateValues.AddRow({'time': time, 'name': 'Property2Name', 'quality': 'GOOD', 'value': property2Value});

...

me.UpdatePropertyValues({values: updateValues});

View solution in original post

8 REPLIES 8
jpenney
2-Explorer
(To:fblondy)

Francky,

How are you calling the service?

James

fblondy
7-Bedrock
(To:jpenney)

In many different ways.

var params = {

    values: undefined /* INFOTABLE */ <-------- THIS is the problem, I've tried to put everything I could think of (only and always Infotables though)

};

me.UpdatePropertyValues(params);

jpenney
2-Explorer
(To:fblondy)

How are you getting the updated values into the infotable? Are you calling the REST API?

fblondy
7-Bedrock
(To:jpenney)

I tried :

- creating objects (name, value) and pushing them into the rows array of an empty JSON Infotable

- creating a single object with an attribute for each property to update and pushing it into the rows array of an empty JSON Infotable

- same as first two but with a JSON infotable with the datashape corresponding to my objects

- same as first two but with a "normal" infotable without shape

- same as above but with the AddRow() method

- with a "normal" Infotable but with the correct shape and both methods (AddRow() and rows.push())

qn
12-Amethyst
12-Amethyst
(To:fblondy)

Hi,

Here is how I use this service:

var params = {

      infoTableName: "UpdatePropertiesInfoTableTMP" /* STRING */,

      dataShapeName: "NamedVTQ" /* DATASHAPENAME */

};

var updateValues = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var time = new Date();

updateValues.AddRow({'time': time, 'name': 'Property1Name', 'quality': 'GOOD', 'value': property1Value});

updateValues.AddRow({'time': time, 'name': 'Property2Name', 'quality': 'GOOD', 'value': property2Value});

...

me.UpdatePropertyValues({values: updateValues});

jpenney
2-Explorer
(To:fblondy)

QD beat me to it! See below for my alternative (and verbose!) update call:

// Create a new blank infotable for passing into the 'update' service

var params = {

    infoTableName: "MyUpdateTable" /* STRING */

};

// result: INFOTABLE

var myUpdate = Resources["InfoTableFunctions"].CreateInfoTable(params);

// add the name field to the datashape for the update table

// this will hold the name of the property to update

var nameField = new Object();

nameField.name = "name";

nameField.baseType = 'STRING';

myUpdate.AddField(nameField);

// add the value field to the datashape for the update table

// this will hold the value of the property to update

var valueField = new Object();

valueField.name = "value";

valueField.baseType = 'STRING';

myUpdate.AddField(valueField);

// add the row that contains the update for temperature

var updateRow = new Object();

updateRow.name = 'temperature'; // << your actual property name here

updateRow.value = 32.0 // << your new value for that property here

// add the temperature row new value to the infotable

myUpdate.AddRow(updateRow);

var params = {

    values: myUpdate /* INFOTABLE */

};

// Finally, update my thing with the properties in the table

me.UpdatePropertyValues(params);

qngo
12-Amethyst
(To:jpenney)

The problem with this method is that the "value" of "updateRow" must be of a type which could be converted to STRING.

fblondy
7-Bedrock
(To:fblondy)

I'll be damned, it works.

I don't understand what was my mistake. I didn't try like James, but tried something similar to what QD did, but with a custom datashape containing name and value as Strings and it didnt work.

I now tried with a dynamic DS (like James) and it worked (probably the only way I had not tried yet)

Thanks

Announcements


Top Tags