You are viewing limited content. For full access, please sign in.

Question

Question

Prevent Saving Draft or Closing Window

asked on December 15, 2016

I have a form to allow a user to edit some values in a database.  For the most part, the form works great.  However, it goes a little weird if a user tries to open two copies of the form, or if the user tries to save a draft of the form and then re-load the task.

On the "Message Start Event" I have it set to not allow the user to save a draft of the form, and of course if they close the window without submitting it, it doesn't save anything.  The issue I'm having is on the second form.  This form is automatically routed to the same user and automatically displayed, so when they submit the first form it immediately pulls up the second form.  But the second form has the button at the top to save a draft, and they can just close the window, and in either case it'll leave an open task for the user that they can resume.

I'd like to either:
1. Prevent the user from using the "Save Draft" button and also cancel the form if the user closes the window (this is my preference).
or
2. Prevent the user from starting a new copy of the process if they haven't finished the last one they were running (this isn't my preference, but I'll take this option if the first option isn't doable).

Does anyone know if this is possible, and if so, how to do it?

Thank you!

0 0

Answer

SELECTED ANSWER
replied on December 21, 2016

I've introduced two changes to my process that so far seem to have resolved these issues.

Issue #1 - When a form is saved as a draft and re-opened, it doesn't display correctly.  This was because I am populating my forms (in one case a table, in another a collection) with the results of a series of database lookups - part of this process includes adding additional rows/records to the table/collection in which to display the database info; each time the window was loaded, it added more rows - got really messy...  To get around this, I added a check value to track whether the data was loaded.  In my Javascript that is called when the form loads, it checks for this check value, if it's not there, it proceeds with loading the form, and finishes by populating the check value.  Then the next time the form is saved as a draft and then re-opened, the check value is already there so it doesn't attempt to reload the values into the form.  Works beautifully.

Issue #2 - I wanted to ensure that multiple users couldn't be working on the same part of the form simultaneously.  This one required some tracking in my database.  My process starts with one form that gives several options, which lead into several different secondary forms, one for each of the options.  I'm fine with multiples of the first form, but I only want one instance of each of the secondary forms to be running at a time.  I added a table to my database with one record for each one of the secondary forms - each record had fields to track a username and a date.  When the first form is loaded, it checks this database table to see if each of the secondary forms' associated records have a name and date populated (or if they are null) - if they are null, it will display the options to access the forms, if they are not null, it will display a message that the process is already started, by which user, and on what date.  Then it was just a matter of adding two workflow processes, one that runs right after the first form, and populates into the database record the current date and the username of the form initiator.  The second workflow process is kicked off after any of the secondary forms are cancelled or submitted - this one will update the database record with null values.  The result is that once a user gets to one of the secondary forms, it has to be cancelled or submitted before any other process can move to that particular secondary form.  So far, this is working to prevent two users from accessing the same secondary form simultaneously.  In the end, I think it's actually pretty user-friendly (even if it wasn't very developer-friendly).

0 0

Replies

replied on June 26, 2017

Matthew,

 

I am trying to do something similar.  I need to have some kind of check value so that a stored procedure is only executed once.  Is there any chance you could provide some more detail around that?  Maybe even a code snippet?

 

Thanks,

Alon 

 

 

1 0
replied on December 15, 2016

Additionally, I do not have the checkbox marked for "Allow the task to be reassigned" - but it still lets me reassign the task...  Is that just because I'm the process admin and a regular user won't have that option, or does the functionality not work like it seems like it should?

0 0
replied on December 15, 2016

There currently is not a way to remove the Save as Draft option from the task view. I think the bigger issue though is what happens that causes issues when Save as Draft is selected from the Task view?

Yes, if you are a admin you will be able to reassign tasks.

0 0
replied on December 15, 2016

The form tries to reload all the database fields again, and ends up with duplicate records in my tables and collections - I need to make changes to my JS to prevent this.  But I'd rather they not have the ability to to initiate multiple copies of the form.

An idea just occurred to me that I haven't tested out yet.  I'm thinking I'm going to add a value in my database with a Workflow to update it.  When they submit the "start form" it'll put a value in the database that shows the form is initiated - and then if the form gets cancelled or completed it will update it again to show it's no longer in that initiated status.  Then if they try to initiate the "start form" again while the check value is showing incomplete, it won't allow them to submit the the form again and give them an error message referring them back to their open task - at which point they can cancel or finish the open task.

0 0
replied on December 16, 2016

You can refer to this post to disable the save draft button which will apply to all the tasks if that is what you want.

0 0
replied on December 16, 2016

Thank you @████████ - I'm checking that out now, it definitely looks promising, and very well may be the best option for my needs.  My only worry is that in that post, it mentioned the code changing between 10.0 and 10.1 - I would be worried about it breaking with future updates.  I'm going to have to think on this...

 

0 0
replied on December 18, 2016

We will look into the built-in functionality for support enable/disable save draft per task.

2 0
replied on December 19, 2016

That would be fantastic!  Thanks @████████!

0 0
replied on January 12, 2017

Show Save Draft button when viewing task or not is now customizable with Forms 10.2 when you design the process.

1 0
replied on January 13, 2017

Fantastic!  Thanks @████████

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.