Email table data in 7.7.4

Hi guys, not sure when the IT department if going to update to 7.8 but till then I suppose I can try this the hard way. So as the subject of the email says, I want to send an automated email at 7:02 am 15:02 pm and
23:02 pm and each email is going to include multiple query results, I do have a Boolean tag that comes on at those 3 times so would it be better just use the, fromAddr, subject, body, html, to, attachmentNames, attachmentData, timeout, username, password, priority)

in the check box component scripting and when the bits come on I send that email or would it better doing it under the Gateway even script?

I use a gateway tag change event script.

This one runs twice a day (*** is redacted info):

[code]trigger ="[]NTU Report Trigger")

if trigger.value == 1:
results = system.db.runQuery(“SELECT Top 3 CAST(Pit_A_Turb AS DECIMAL(18,1)) AS ‘Pit A’, CAST(DAF_A_Turb AS DECIMAL(18,2)) AS ‘DAF A’, CAST(DAF_B_Turb AS DECIMAL(18,2)) AS ‘DAF B’, CAST(SF_A_Turb AS DECIMAL(18,2)) AS ‘SF A’, CAST(SF_B_Turb AS DECIMAL(18,2)) AS ‘SF B’, CAST(SF_C_Turb AS DECIMAL(18,2)) AS ‘SF C’, CAST(SF_D_Turb AS DECIMAL(18,2)) AS ‘SF D’, CAST(SF_E_Turb AS DECIMAL(18,2)) AS ‘SF E’, CAST(Surge_Tank_Turb AS DECIMAL(18,2)) AS ‘Surge’, CAST(Pipeline_Turb AS DECIMAL(18,2)) AS ‘Pipeline’, t_stamp AS ‘time stamp’, username FROM Frac_Office_Data WHERE t_stamp IS NOT NULL ORDER BY t_stamp DESC”)
results = system.dataset.toDataSet(results)
html = system.dataset.dataSetToHTML(1, results, “*** NTU Data”)
bodyhtml = “

*** NTU Data

”+ html
body = bodyhtml
recipients = ["***@***.com", “***@***.com”, “***@***.com”]"***.local", fromAddr=“ignition@***.com”, subject="*** NTU Data", body=body, html=1, to=recipients)

If at all possible, it’s nice to run these kind of things (that do something at some tag change or some time) on the Gateway rather than in a component script. If it’s in a component script, you need to make sure that you always have one client up with that component’s window open, but you have to deal with making sure you don’t duplicate things if two or more clients are up with that window open. In the Gateway, you won’t have duplication issues and your Gateway should (ideally) always be up.

When (not if :slight_smile: ) you upgrade to 7.8, you can put all that into a report that gets emailed. These concerns with making sure clients are open at the right time were a big motivator behind our decision to move report execution to the Gateway.

Never got to thank you for your response! I did use this but we ended up updating to 7.8 and I started playing with the reporting module and boy I never looked back! lol

Thanks for the suggestion, I do try to use the gateway even script for stuff like this and it has helped a lot.
I’m using reporting module and it’s amazing and keeps getting better, I have one question tho, what would be the best approach if I wanted to manually trigger a report to be sent out? the simplest example is a memory BOOL tag that gets triggered using a button by user, now is there a way I can trigger the report execution to that tag?

I’d use a tag event script – when the value changes to 1, call

1 Like

If it’s coming from a button press in the first place, there’s no reason the button’s actionPerformed event can’t call executeAndDistribute() itself, cutting out the tag in the middle.


Perhaps I should have looked at the scripting section of the manual first :stuck_out_tongue_winking_eye:
One other question, so my reports are mainly email and I have added bunch of email addresses, If I manually execute and distribute the report, will it by default execute the email action I have in there with all the addresses or do I still have to specify all the addresses in my script? I suppose if it doesn’t I can create user groups and put those addresses in there and just use that in the script.
I assume if I have two different email actions ( say one to management, one to supervisors with different timing) there is no way to specify if I want to execute the first email action or second one correct?
I’m just asking these because they just popped in my head, I definitely can think of ways to get around this and get the results I want, I just figured I pick your smart brains first :nerd:

The scheduled actions are completely separate from the script actions.

Duh, of course. That’s what I get for looking at the forum before sufficient caffeine intake. :flushed: