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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Access Second Infotable From UpdatePropertyInfo

karnoia
10-Marble

Access Second Infotable From UpdatePropertyInfo

Good morning everybody,

I need to access a second infotable (Lets call it "Reasons") from the updateproperty of a first one (Lets call it "Data"), and I can't find how. Since both infotables have a very different size (4-10 rows vs 600-4000), I didn't want to send the data on the same infotable. I know that I could read one, save the data on a global level and read the second one, but the problem is that my "Reasons" one conditions the "Data" one, so I would always need to be sure that the updateproperty of the "Reasons" goes first, and for that, as far as I know, the only solution would be to use 2 different services, one after another, to feed this infotables. And truth be told, I don't like that solution too much since I am not the only person that might use this widget.

Do you know if there is any syntax to do something like this? I have attached what I was trying to do, which might help to understand what I mean.

Regards,
Josue Nanin

if (updatePropertyInfo.TargetProperty === 'Data') {


var AxisLabel = this.getProperty('AxisLabel');

var MinutesValueField = this.getProperty('Minutes');


console.log("updatePropertyInfo Data");

console.log(updatePropertyInfo);


var dataRows = updatePropertyInfo.ActualDataRows;

var nRows = dataRows.length;

var datagenerated = [new Object()];

var MinutesValues = [];


for (var rowNumber = 0; rowNumber < nRows; rowNumber++) {

      var row = dataRows[rowNumber];

      var MinutesValue = row[MinutesValueField];

      if (MinutesValue === undefined){var MinutesValue = null;}

      MinutesValues.push(MinutesValue);

}                   




updatePropertyInfo.TargetProperty === 'Reasons'

var ReasonValueField = this.getProperty('ReasonValue');

var ReasonColorField = this.getProperty('ReasonColor');

console.log("updatePropertyInfo Reasons");

console.log(updatePropertyInfo);

console.log('ReasonValue');

console.log(ReasonValue);

console.log('ReasonColor');

console.log(ReasonColor);


var dataRows = updatePropertyInfo.ActualDataRows;

var nRows = dataRows.length;

var datagenerated = [new Object()];

var ReasonsValues = [];

var ReasonColors = [];


for (var rowNumber = 0; rowNumber < nRows; rowNumber++) {

      var row = dataRows[rowNumber];

      var ReasonsValue = row[ReasonValueField];

      var ReasonColor = row[ReasonColorField];

      if (ReasonsValue === undefined){var ReasonsValue = null;}

      if (ReasonColor === undefined){var ReasonColor = null;}

      ReasonsValues.push(ReasonsValue);

      ReasonColors.push(ReasonColor);

}

console.log('ReasonsValues on the array');

console.log(ReasonsValues);

console.log('ReasonColors on the array');

console.log(ReasonColors);

2 REPLIES 2
AdamR
14-Alexandrite
(To:karnoia)

Hi ​Josue,


You could code into the widget an event which is triggered on the update property of the "Reasons" infotable.  This event would then trigger the service that retrieves the infotable for the "Data" needed.


You can also set these bindable infotable properties to be required, and possibly throw an error/warning message if the event is not bound to a service.


Thanks,

Adam

karnoia
10-Marble
(To:AdamR)

Hi Adam,

Thank you for the ideas!! I like the trigger event one, I might try that the next time. What I ended up doing was reading the values from the infotables (they ended up being 3 different ones) on the updateproperty of each and save the values on arrays on global level. Then I checked that if I send several infotables with the same service on thingworx, the  if (updatePropertyInfo.TargetProperty === 'XXX') will follow the order of coding, so I just put as last updateproperty the "Data" infotable one (wasn't sure about this since the multithread has given me problems before).

If someone doesn't understand what I mean, I can add the new code.

Anyway, as I said before, thank you for the ideas Adam.

Regards,
Josue

Announcements


Top Tags