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

Question

Question

Form Preview Option Stopped Working

asked on August 20, 2024

Hello LF Community,

I have an interesting situation that I'm not sure what's the reason of it. 
We have a form that creates invoices for certain clients. These clients have a database of codes,descriptions,costs for each line of the invoice. The form is user friendly for our employees as they just need to enter the charges in a casual way rather than knowing the code and description that the client wants to see on the invoice. Thats being handled after the form submission in workflows with many conditional sequences.

That's been said, there is a preview function in the form that when user enter the charges, they were able to see what the invoice will look like after waiting a bit. The invoice page would be created after running in workflows, entry id of the invoice page would be assigned to a field on the form then it would show itself on a different tab on the browser. The user don't need to submit the form at this point and their form task would be open still on its on tab. This logic was working fine for years but it suddenly stopped working.

See the javascript code and the attached pictures.

Now what happens is, when user click on preview button, the form goes in to loading then eventually dissappears. The user sees the inbox on the browser. After a while when they keep refreshing the page, they see their task again and when they click on the task link, the invoice appears on the different tab, now they can review and go back to their form and submit it.

It almost like processing time is increased and the form doesn't stay open. The preview function became inconvenient and I'm not sure how to handle that.I'm not much of a coder and getting this done was a big hassle before. Do I need to add or change anything on the code? Any ideas or suggestions would be greatly appreciated.

We use laserfiche 11 and this is on classic form designer.
 

Thank you everyone!



The Preview Code:
 

// Preview open new tab logic
  var previewEntry = $("#q161 input").val();
  var link = "https://sjlf1v.pfcollins.net/laserfiche/DocView.aspx?db=PFC&docid=";
  if (previewEntry.length > 1){
    var fullLink = link + previewEntry;
    download(fullLink);
  }

  // Function to open new tab and check if it was blocked
  function download(link){
    var popout = window.open(link);
    if (checkPopup(popout)) {
      popout.focus();
    }
  }

  // Function to check if popup was blocked and show dialog if it was
  function checkPopup(window){
    if (!window || window.closed || typeof window.closed == 'undefined') { 
      $("#dialog").dialog({
        width: 700
      });
      return false;
    }
    return true;
  }
});

1.png
2.png
3.png
4.png
5.png
6.png
7.png
1.png (47.3 KB)
2.png (27.65 KB)
3.png (11.94 KB)
4.png (28.55 KB)
5.png (14.43 KB)
6.png (64.17 KB)
7.png (32.56 KB)
0 0

Answer

SELECTED ANSWER
replied on August 20, 2024

There is a little debugging you could do, but I would look at some of the forms instance history and see roughly how long these preview workflows were taking when the preview process was working as expected and how long those workflows are taking now.

The easiest solution is to update the 40s default task load timeout as described here https://answers.laserfiche.com/questions/173823/Forms-timeout-when-task-loads-to-same-person although this has the caveat of affecting all processes which should be mostly fine, but processes that error will now take longer to show that something went wrong.

I would highly recommend trying to optimize the preview workflows so they can run faster than 40s because this is already a fairly long time to wait for a preview.

The harder but better solution would be to kick off the workflow asynchronously and kick the form directly back to the user. When I have built document generation preview processes in the past what we did was have the workflow invoked from the form create a blank entry in the repository and name it what it needed to be based on the generation data, and then kick off another workflow but not wait for it to finish. This is what sends the form right back to the user in a matter of seconds. The newly kicked off workflow performs the work of creating/modifying the document. With this two features on the form enabled a simpler "wait for generation"

1. Use the document name to identify the document as still waiting. For example "Generating - Freight Invoicing Worksheet"

2. User can then use the refresh button within the repository popout to check for generation to be complete

This is better because the user always gets the task so it doesn't vanish into the abyss while workflows run, and you can give them pseudo loading indications either through the document name or a metadata field.

1 0
replied on August 20, 2024

Hi Zachary,

 

Thank you for your answer and detailed explaination, that makes sense. I'll look into building the wait for generation logic. I really didn't want to mess with the Javascript so this is way better.

 

Thank you!

0 0
replied on August 20, 2024

Ya it looks like the JS is pretty straightforward. The only thing I'll add to my origin post was make sure you are passing the entry id back in the parent workflow regardless of how you handle the document generation. This way the JS can load the ID and when the user clicks the button the repository window opens up and displays the document either pre or post generation. Its then up to you to figure out the best way to tell the user it is still generating.

 
 
 
1 0

Replies

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

Sign in to reply to this post.