Gateway Event Script sending two emails [Solved]

In regards to this post

The gateway script is working but it's sending me two emails instead of one. I mean, I only have one instance of executeAndDistribute but when I trigger it (to when the tag is = 1) its sending me two emails. Anything else I should check to make sure it only sends one email?

Its a shot in the dark, but any chance the report has a scheduled event configured in it? Also I would double check that the your tag change script specifically confirms the value is 1 otherwise it may trigger going high or low.

You could also try putting a logger into your script to confirm it only is executing once there.

no it doesn’t have a scheduled event configured :frowning:

how can i put a logger on my script?

     log=system.util.getLogger("Logger Name")
     log.warn("Message goes here")

Something like this should work. I use these temporarily to mark conditions in the system quite a bit during debug.

1 Like

oh cool brb, i’m gonna try that and see what goes on

currently this is my code

exeRep = system.tag.read("[edge-ksvsclient_edge]ExecuteReport").value

if exeRep == 1:
	#code for system.report.executeAndDistribute
	system.tag.write("[edge-ksvsclient_edge]ExecuteReport", 0)
	log=system.util.getLogger("executeReport")
	log.warn("%s"%exeRep)
	
else:
	log=system.util.getLogger("executeReport")
	log.error("Failed")

I think the reason why its sending two emails is because of the tag write

system.tag.write("[edge-ksvsclient_edge]ExecuteReport", 0)

What im trying to do is when the user clicks on a button from the edge client it writes 1 to the tag "ExecuteReport" and from our central server it will send the report and then I want to reset the tag back to 0. This part works - I am getting the email and the tag is writing back to 0. But what I don't understand is why the tag write would cause the email to be sent twice? Any suggestions on the workaround for this that I could try? I tried putting the tag write outside the if condition but that didn't work out as well.

i was able to make this work instead of

if exeRep == 1:

I used

if newValue.value:

yey

1 Like