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

How to reference data table, get specific column value, and use as entry into a separate infotable

SOLVED
Participant

How to reference data table, get specific column value, and use as entry into a separate infotable

Hi,

For a current customer I am trying to implement a service that will record the Fault messages of the machine.

I've set up an infotable property on the asset that would house the recorded faults.

I've also set up a data table holding the fault code reference document that has a numerical code and string for each fault.

 

What I need to do, is when an Alert on the faulted PLC tag is triggered, to get the numerical code from a seperate PLC tag, reference that code in the data table, get the string equivalent, then add a row with all that information to my asset fault history infotable property.

 

I cannot get my javascript code to work, I'll paste below what I have currently, I am wondering now if it is easier to use data tables for both tables listed above or if this set up should work?

 

To clarify, I am using a configured Alert on the Faulted property (boolean) to trigger a subscription with the following code:

 

var PLCFaultCode = me.Current_Fault_Code;
var propertyString = "Fault_History_Table";

var query1 = {
"filters": {
"type": "EQ",
"fieldName": "FaultCode",
"value": PLCFaultCode
}
};

var params1 = {
t: Things["Mahle_GapGrind_FaultMessages_DataTable"] /* INFOTABLE */,
query: query1 /* QUERY */
};

// result: INFOTABLE
var result2 = Resources["InfoTableFunctions"].Query(params1);

me.AddInfoTableValueStreamEntry({
propertyName: propertyString /* STRING */,
value: result2 /* INFOTABLE */,
timestamp: undefined /* DATETIME */,
});

 

Any help greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to reference data table, get specific column value, and use as entry into a separate infotab

Hi @ateed 

 

From the code you seem to be passing a dataTable as parameter t, that is then passed to Resources["InfoTableFunctions"].Query(params1);

This t parameter should be an infotable not a data table.

You can maybe test 

var params1 = {
t: Things["Mahle_GapGrind_FaultMessages_DataTable"].QueryDataTableEntries({
maxItems: undefined /* NUMBER */,
query: undefined /* QUERY */,
values: undefined /* INFOTABLE */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
}) /* INFOTABLE */,
query: query1 /* QUERY */
};

 

instead, just to test that it goes further.

You can then check with service QueryInfoTablePropertyHistory if you see the update (I do)

 

Thanks

Hope this helps

Christophe

 

View solution in original post

2 REPLIES 2

Re: How to reference data table, get specific column value, and use as entry into a separate infotab

Hi @ateed 

 

From the code you seem to be passing a dataTable as parameter t, that is then passed to Resources["InfoTableFunctions"].Query(params1);

This t parameter should be an infotable not a data table.

You can maybe test 

var params1 = {
t: Things["Mahle_GapGrind_FaultMessages_DataTable"].QueryDataTableEntries({
maxItems: undefined /* NUMBER */,
query: undefined /* QUERY */,
values: undefined /* INFOTABLE */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
}) /* INFOTABLE */,
query: query1 /* QUERY */
};

 

instead, just to test that it goes further.

You can then check with service QueryInfoTablePropertyHistory if you see the update (I do)

 

Thanks

Hope this helps

Christophe

 

View solution in original post

Re: How to reference data table, get specific column value, and use as entry into a separate infotab

Yes, so my problem was mixing data tables and infotables like you pointed out. I ended up changing the code quite a lot and it's working now, thanks for the help!

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!