I am using Ignition Edge 8.0.13
I am binding my table data to audit log through Functions->Binding Function->Audit Log
I need to filter both “Tank” and “Pump” in the Target Filter.
If i type in %Tank%, i am able to see those audit logs related to Tank only.
If i wanna see both Tank and Pump, i have tried:
%Tank% , %Pump%
%Tank% && %Pump%
%Tank% AND %Pump%
But these methods are not working…
Can someone tell me how could i include in those filters? As there is no SQL Query option available.
let me understand:
if you need to filter all the records that contain both the word “Tank” and “Pump” in the same row you should use this filter:
important: the order of the words matter and this will find:
but won’t find
If you need to retrieve alla the records that contain Pump OR Tank, seems like the Audit log function can’t achieve your purpouse.
A SQL Query binding in the Data property of the table could, try this:
, EVENT_TIMESTAMP as Timestamp
, ACTOR as Actor
, ACTION as Action
, ACTION_TARGET as "Action Target"
, ACTION_VALUE as "Action Value"
, STATUS_CODE as "Result Code"
, ORIGINATING_SYSTEM as System
, ORIGINATING_CONTEXT as "Context Code"
WHERE (ACTION_TARGET like '%Tank%') or (ACTION_TARGET like '%Pump%')
Thank you for replying and sharing the script!
But i am using Ignition Edge, whereby i cant use the SQL Query binding method…
Below is the screenshot of the table’s property binding for your info.
You’ll have to script your filter entirely in jython, using a propertyChange event. Bind the unfiltered data to a custom property (of type Dataset), and monitor its changes. The propertyChange script would write the new dataset with the desired rows to the table’s data property.
(I would normally recommend the view() expression function from my Simulation Aids module, but it isn’t allowed in Edge.)
hello, sorry for the delay. Actually I have no experience of Edge, but if you can’t run a sql query you have to do the “hard work” by yourself.
As pturmel suggested I would do something like this:
# place this code in the propertyChange event of your component
# unfiltered is your property containing the unfiltered data
if event.propertyName == "unfiltered":
# transform it in a Pydataset this way you can iterate through each row
pyAlarms = system.dataset.toPyDataSet(unfiltered)
# collect only the rows matching your criteria
rows = [row for row in pyAlarms if ("tank" in row['ACTION_TARGET']) or ("pump" in row['ACTION_TARGET']) ]
# create the new dataset and return it
header = system.dataset.getColumnHeaders(unfiltered)
filtered = system.dataset.toDataSet(header, rows)
Hi Phil, thank you for the suggestion, would definitely try it!
Thank you so much for the suggested script, i will try out and see how it turns out!