is there anyway to block user from closing the browser before finishing submission in SmartForms?


Userlevel 5
Badge +16

hello everybody, how can I block user from closing browser before finishing submission?

can I do rollback transactions if a user closed browser during the submission?

 

the problem is: if a user close browser before finishing sumbission, it will excute some methods and create records in my database, sometimes it doesn't reach the start workflow rule, in this case i want to remove the saved records!

 

any solution?

 

 


12 replies

Userlevel 1
Badge +8

Hi Steve

 

I'm not aware of any way to prevent a user from closing a browser before an event is triggered.  Smartforms doesn't have any rules that trigger on the browser level (.e.g when browser closes).

 

There is probably a way to capture the window unload event before a browser tab closes in Javascript, but it would prove difficult to hook this up to a Smartforms event. In any case this won't stop a user from using task manager to close the browser.

 

Can I suggest that you look at your form logic and see if you can only trigger any data saving events on the submit event. If you are using listviews to capture data and then a submit button to start a workflow, look at doing all of the data saving in the submit button rule.

Userlevel 5
Badge +16

Thank you dear, well all my events are triggered when the submit button is clicked, but the user close the window while submitting, its like the user click on submit and close the window directly without giving it time to finish all the events. I know it's kind of impossible to control this in smartforms, I just wanted to make sure if there is any solution apart from using JavaScript.

 

P.s i tried to use the smartobject rollback transaction feature but it didn't help!

 

Thank you again.

Badge +10

What if you show a popup message box as soon as the submit button is clicked. Saying something like, "processing!!! please do not close window, window will close automatically when processing is complete." and the end of the submit rule you add a rule to colse the window automatically. 

 

Userlevel 5
Badge +16

Thats what I did, the client wants to remove added records from the database if this case happens.

I don't see it possible in smartforms.

Userlevel 4
Badge +13

Hi Steve,


 


I think instead of looking for a way to block a user from closing a browser before finishing submission or to do rollback transactions if a user does close a browser during the submission, rather look at improving your performance so that the view executes the rules faster.


 


I suggest playing around and changing the 'when actions execute'.


Example: Looking at the rule construction below you will see that when the advanced condition is executed that all items in it are then completed one after another and then the message is show, then a SmartObject is executed.


By changing the "then complete the following one after another and then" actions your performance can be increased depending on the selection made.


 


When Button is Clicked


 


    if
an advanced condition is true

 

        then complete the following one after another



        then on good question smo SmartObject, execute its Save method

 (configure)


        then show a message to the user

 (configure)

 

When you change the 'completed one after another' you have these options:


  1. then complete the following one after another
  2. then complete the following concurrently
  3. then start the flow asynchronously
  4. then complete the following in a batch

At the moment I think that 'In a Batch' is the fastest action.


 

When you change the 'then' you have these options:


  1. then
  2. also
  3. and
  4. asynchronously

Please see these documents for references:


How to change when Actions execute in the Rule Designer


Understanding Rules


 


Kind Regards,

Raymond
Badge +10

That sounds like a unreasonable demand from the client. How long is it taking on average to record everything at the moment.

Userlevel 5
Badge +16

my rules structure doesn't allow me to change the way of execution too much, because I have couple of events that updates records in the database, for example:

 

if an advanced condition is true
 
        then complete the following one after another
        then on good question smo SmartObject, execute its Create method
 (configure)
  then on good question smo SmartObject, execute its Update method
 (configure)
 
then on Employee smo SmartObject, execute its Create method
 (configure)
then on Employee smo SmartObject, execute its Update method
 (configure)
Etc... 
 
I have 15-20 rules related to each other, so I can't Create and Update at the same time, the execution method "In a batch" solves my problem but i can't use it everywhere
 
any way Thank you, your solution increased the performance significantly.

 

 

Userlevel 5
Badge +16

Hi  @s0m3one

 

it is unreasonable, it takes 3-4 seconds to complete submission, the user can't even wait to see the confirmation message.

 

it's funny that the user click submit then close in a second.

Badge +10

Hi,

 

I have a question on why you are executing a create and update on each smartobject?

If you are using K2 SmartBox smartobjects, you can create all the fields necessary using only the Create method.

If you can do everything only with the Create method you effectively would halve the time it would take to execute.

 

Please let us know.

 

Regards,

JohanL

Userlevel 5
Badge +16

Hi  @JohanL

 

On create I retrieve the Identity to generate another ID, I have to columns in the table, Request ID and Request Full ID.

 

Reuest ID is the identity and the request Full ID is (Year/Identity/ExtentionValue From another field)

 

so after creation i need the identity to generate other ID's.

 

P.s Im using smartObject.

Badge +10

Hi Steve,

 

Thanks for explaining why you need the extra methods, it makes sense.

To be honest, I don't think there is anything natively in K2 smartforms which will stop the user from closing the window.

You can try investigating something with JavaScript that will stop the window from closing.

You can put the JavaScript in a hidden Data label (haven't done it myself but theoretically it should work) which will then capture the  window.Close method and can take action from there.

It is a long shot, but might work.

 

Hope this helps!

Regards,

JohanL

Userlevel 5
Badge +16

Hi  @JohanL

 

Thats what I've done recently just to make the user waste some time.

 

Thank you!

Reply