Gateway Timer script not working

I have script to post data to web services-

Using Gateway timer script runs, But scripts failing sometimes using timer ,whereas using user button they work 100%.
Any solution or improvement we can do.

Sample code-,-15);,-1);

SPC_QC=system.db.runPrepQuery("SELECT X1,X2,X3,X4,X5,.....X10 MasterData where  TS>? and TS<=?",[TS1,TS2],'SPCD');

#by iterations data converted to dictionary and posting single data point of dict using loop

 dict1={};#key values will be in dictionary
  system.db.runPrepUpdate("UPDATE MasterData SET  POST_STATUS=1 where IDNum=?", [id], 'DB1');

  system.db.runPrepUpdate("UPDATE MasterData SET  POST_STATUS=0 where IDNum=?", [id], 'DB1')

What error are you getting in your server logs? If it’s not working the gateway the errors are being logged. What do you see?

1 Like

I don’t see any error in gateway logs, Even we have some event based script to perform posting every 10 sec or 1 minute (event occurs).

So how do you know this is failing exactly? What is not happening for you that you are expecting to happen?

1 Like

If few data points not posted successfully, I can see them on table(as failed post).
Using same gateway script On button event I can reprocess all failed data points.

Oh I see this is a SepaSoft function. Though some people here are familiar with it, you may get better help contacting their support team directly.

I don’t see how that is gonna work. j is not defined


On this note - put your entire function into a script library and call it from your button press/gateway event script to ensure the exact same code is running.

I see also your query looks odd as there is no FROM keyword in it so I don’t know if you copied things over and modified them to hide certain things or if that’s a actual typo in your real code etc.

Also in python just so you know you don’t have to end your lines with a ;

Yes Its not complete code ,as it executes without any error. Question is why few executions didn’t happen(timer based gateway script )

If you think scripts should work always no matter the scope, I’m afraid you’re wrong. That would be my answer to your question.
Since you don’t post further info, I doubt someone can help, likely speculate :man_shrugging:


For example one common issue going from a client script to gateway script is that in a vision client you don’t have to specify which database you are using and the default database for the project will be used but in the gateway context you must provide the database.

resolved by using shared option