apps-script: preventing multiple firing of handlers? - google-apps-script

I'm seeing multiple submissions on a form, presumably because someone is double-clicking a submit button. Is there a good way to prevent this in GAS? I suppose I could set up a global variable via JSON, and use that to determine whether or not to execute the handler, but it seems a bit clunky.
Thanks.

create a client Handler that disables the submit button before the rest of your code is executed.
You can add a client handler anywhere you would add a server handler of any type, and it works entirely on the client without any server roundtrip.
See Serge insas comment below!

Related

Sending email notification on error using SSIS

I am currently implementing Send Email notification on error in my SSIS package. It currently works. Just want to check if this is the right way of doing it.
If you want to trigger your mail task when any error occurs, consider the "Event Handlers".
This SimpleTask article provides a very good overview of the event handlers
https://www.red-gate.com/simple-talk/sql/ssis/ssis-event-handlers-basics/
SSIS event handlers are the simplest means of turning an SSIS script into a reliable system that is auditable, reacts appropriately to error conditions, reports progress and allows instrumentation and monitoring your SSIS packages. They are easy to implement, and provide a great deal of flexibility.
Sample screen shot:
Using event handler provides some advantage - you need not connect each task's failure. The system will call your event handler for the error.
Also, note there are 2 event handlers of interest:
OnError
OnTaskFailed
https://learn.microsoft.com/en-us/sql/integration-services/integration-services-ssis-event-handlers
OnError event - This event is raised when an error occurs.
OnTaskFailed event - This event is raised by a task when it fails.
One thing to watch out for is that you event handler may be called multiple times depending on the number of errors.
I think there is no standard answer to this question. But here are some of the tips that I am be able to think of.
First, not very sure what kind of plain text you are trying to send out, if they do not have dynamic text body, you could put that send email task in the event handlers right to the Control flow, Data Flow... tab, and put that on error for specific tasks.
Second, I personally do not prefer to use Failure output, you may need to increase the number of MaximumErrorCount so that the package could executed successfully, but sometimes the real error might not be detected because together with error output, the total error numbers is still less than the threshold.
Third, if you are sending the same text, and you will schedule it as a job in SQL Server Agent, you could go to Notifications option page, set the Send Email, basically it will be informative.
Last but not least, the Send Mail task supports plain text only, not any formatting like email coded by html & CSS, if you need to take the formatting into consideration, that might not be your choice, you could use Script task using C# or creating html page by using XML statement from your SSMS and put into a stored procedure, then sent out the html by Database Mail, you will find this tool under Management folder in your SSMS.

Can I block a form submit action after first click

On a webpage, is it safe to block a submit action after user clicked it once (to avoid double posting) or is there a risk that I now block my user, in case of no/bad connectivity, post not reaching the server etc..
So in other words, can I trust that my post request always reaches the server and back to the user?
It is ok to disable button on Submit... but please make sure that you execute SUBMIT script after you have disabled it...
p.s. Common behavior is that submit button does not proceed to submit after you disabled it, you should do it manually.
To encounter no/bad connectivity, you can set javaScript timer that will return submit button to its normal state after some time, so user can click it again
Ideally you should send a server call and disable the submit button and wait for the response to comeback and if status is failed enable submit button otherwise do nothing and process the response as you need it
i think you are using javascript for making a server call if yes then it's very easy to pass a callback and listen for the response

WebSockets and Async/Sync parts of it

How does WebSockets exactly work? Implementing them seemed weird.
First you construct the object with the address, then you define the callbacks like onopen which is called when the connection is opened. Now how does that happen if I told the websocket to connect while constructing it? If the constructor connects in async way, is it guaranteed that my onopen will be called.
To sum it up:
1) When does the websocket decide to connect, when I declare all callbacks?
2) Is send() method async? If so, is there a way to call it sync?
EDIT: I have found out send() is async, there is a bufferedAmount attribute that returns the amount of data that is buffered to be sent. However, the second part of the second question still stands.
I've found a good way to explain how this part of an event loop works is this:
In an event loop, everything runs asynchronously, except for your code.
Consecutive statements will always be executed before the next event loop iteration happens. This means that you can safely assign event listeners to the ws object, because you know that it cannot call them before current iteration completes.
As for sending, as you noticed correctly, those values are generally buffered. However, it's probably a bad idea to send any messages before the onopen event is fired, as you're buffering messages on a not yet opened connection.
I hope this answers your question.

GAS serverhandlers, what's the difference?

What's the difference among
.createServerHandler,
.createServerClickHandler,
.createClickHandler
?
Thanks
referring to the doc method createServerClickHandler(functionName) - deprecated 2012-03-06
in favor of createServerHandler which creates the 'generic' server handler in the Uiinstance. The createClickHandler is one of many methods that defines the behavior of the handler : click/change/mouse/key... (see doc of the element you use) and the possible options will be different depending of the type of element.
Note that the autocomplete feature allows to see easily what handlers are available for each Ui element.
Also important to remember, a server side handler sends your request to the server to perform the and then sends the request response back to your application, which can have some latency.
If you have a task like disabling a button immediately after it is pressed, you can use a client handler which performs the operation inside the browser and doesn't have the latency that a server handler would have.
More info:
Handlers in general
https://developers.google.com/apps-script/guide_user_interfaces#UIUpdate
Client handlers
https://developers.google.com/apps-script/guide_user_interfaces#ClientHandlers
Hope that helps,
Ryan

Start up order for Oracle Forms

I have to modify an Oracle Form but cannot find my way to start.
What is the start up order for a standard form? That is which event, trigger etc will be called at form load, canvas load, etc. I assume that it is When-New-form-Instance but a cannot get it to stop at a break point on the first line of this trigger.
I am getting
FRM-40735 ON_ERROR trigger raised unhandled exception ORA-06508
Which I suspect means I do not have my environment set up correctly but I have done the same as others at this site. So I thought to start with debugging and try to identify which call is failing
PRE-FORM fires before WHEN-NEW-FORM-INSTANCE. Check what's defined in PRE-FORM trigger.
Also, your ON-ERROR trigger is giving a ORA-06508 error, so might want to check what program unit is being referred to in the ON-ERROR trigger
To get a start in trying to find the source of the error, try disabling custom code in forms. If the error does not persist when custom code is disabled, you'll have to start tracing through CUSTOM.PLL to find the source of the issue.