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

How to reference datatable, retrieve row value, and update separate table.

ateed
4-Participant

How to reference datatable, retrieve row value, and update separate table.

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 query = {
"filters": {
"type": "EQ",
"fieldName": "FaultCode",
"value": PLCFaultCode
}
};

var params = {
t: Things["CUSTOMER_GapGrind_FaultMessages_DataTable"] /* INFOTABLE */,
query: query /* QUERY */
};

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

 

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

 

1 REPLY 1
Top Tags