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

Question

Question

Delay form submission until workflow completes

asked on November 25, 2020

Here is a simple use case of what we are trying to accomplish...

1. A form has 3 sections

     a. Add Part Number (a text field)

     b. Edit Part Number (a drop-down of existing part numbers and a text field for the modified part number

     c. Delete Part Number (a drop-down of existing part numbers)

2. User adds a new part number, submits the form and it reloads back to the form page

3. Workflow is triggered that adds the part number to the SQL field that is used to populate the edit and delete part number drop-downs.  However, since the "submission" doesn't wait for the next and only step (the workflow) to complete, the user has to reload the page to see the part number in the drop-down fields.

This is an over-simplified use case, but you get the idea.  The form has one activity in the process model...run a workflow that updates a SQL table.  I need that to run before the page loads back to the form so it is updated.

0 0

Replies

replied on November 25, 2020

Hi Jason,

How do you implement "reloads back to the form page"?

If I understand correctly, by 'form page' you mean the same form in first submission, right? What will be the next step when user is reload back to it?

0 0
replied on November 30, 2020

Yes, that is correct.  It would reload the same form.  

 

For Example, if I use the "Add part number functionality" and I add a new part number and submit the form.  That would trigger a workflow that writes the new entry to SQL.  The form then redirects back to the same form after submission.  You click the edit part number option.  The part number dropdown is populated by the same SQL field that the "add part number" field updates, but the new part number is not in the list because the form loaded so fast the previous workflow that adds part number has not completed yet.  If you manually reload the page to run the lookup again, it is now there.

0 0
replied on December 2, 2020

I see. I was thinking use a user task after workflow service task and configure message start event to 'Automatically load the next task if the same person is assigned to it'. It will wait for workflow service task completed then show user task form.

But it won't work in your case, as you still want to be able to start new submission when back to form.

0 0
replied on December 11, 2020

With some testing, I was actually able to make this work.  I'm just not sure why it works.  If my process model has the 3 steps (start, workflow, end) as mentioned above and I check the option on the start event to automatically load the next task is assigned to the same user, it actually does exactly what I need it to.  Since Forms is set to wait for the workflow to complete before proceeding, the actual submit action waits to perform the ending redirect until the workflow completes running.

I created an example that runs a workflow. 

1. The Forms starting event is set to automatically load the next task if the same user is assigned.

2. The workflow task is set to wait until the workflow completes.  The workflow itself contains a script that pauses for 15 seconds.

3. The end event redirects to www.google.com

 

When I run it and submit the form, it pauses for 15 seconds and then redirects to www.google.com...exactly what I wanted.  The question is, why does this work?  You can't assign the workflow activity to a user, so does it just apply to everyone?

 

Fun additional fact...for some reason when I typed www.google.com in this Answers text editor, it loaded the below highlighted box.  Anyone have any idea what it is?

1 0
replied on December 13, 2020

I was not aware of the behavior. It looks like that when the option is enabled, Forms try to load next task for current user. While, the next task is workflow and it waits for it completes so as to load the next task after it if any. 

Glad to know it works!

0 0
replied on November 30, 2020

If you are starting the workflow from the process diagram would setting this work?

0 0
replied on November 30, 2020

Hi Aaron.  That was my initial thought as well.  The problem is, that doesn't impact the actual submission.  See the attached graphic.

 

  1. User Submits a form
    1. It is set to redirect back the the same form page after submission so they may continue entering additional items.
    2. It is that "redirect" that needs to pause
    3. The workflow triggers after the submission, so the redirect after the submission is not impacted.

 

There is a practical use case that I can detail out, but I didn't want to type it all out if it isn't needed since it is lengthy.

Diagram1.png
Diagram1.png (56.64 KB)
0 0
replied on November 30, 2020

I'm surprised that that feature isn't in the end event instead but a simple fix could be to add a script in the thank you message instead that redirects to the form after a set amount of time. This may not work because you aren't waiting for the workflow to complete so it might reload too soon but it should work better than nothing.

<script>$(document).ready(function(){setTimeout(function(){ window.location = "https://yourwebsite.com/form"; }, Set the time in milliseconds here);})</script>

below script will send you to YouTube after one second on the page.

Hope this helps!

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

Sign in to reply to this post.