Displaying a Loading Banner While a Background Process Fetches a Document

I have a Rich Text Icon component that is used to download a PDF document. When the user clicks the download link, a background process is triggered using a!startProcess() to fetch the document based on a primary key. The process takes approximately 5–10 seconds to retrieve the document and return it to the interface.

During this processing time, I would like to display a banner message above the icon, such as:

"Your document is being fetched. Please wait until the download icon appears."

I attempted to implement this using a local variable and a Dynamic Link. In the saveInto, I included both a!startProcess() and an a!save() to update a local flag variable that controls the banner visibility. However, I observed that the local variable is not updated immediately when the link is clicked. Instead, it gets updated only after the process started by a!startProcess() completes.

Is there an alternative approach or recommended pattern in Appian to display a loading or processing message immediately when the user initiates the document fetch, while the background process continues to run?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    document based on a primary key. The process takes approximately 5–10 seconds to retrieve the document and return it to the interface.

    If you are retrieving using primary key, then you should investiagte the reason behind 5-10 s in query. Ideally it should be in milliseconds so you should definitely optimise your query. 

    In the saveInto, I included both a!startProcess() and an a!save() to update a local flag variable that controls the banner visibility. However, I observed that the local variable is not updated immediately when the link is clicked. Instead, it gets updated only after the process started by a!startProcess() completes

    saveInto executed saved in the order they appear within saveInto expression. Most likely your startProcess() is followed by the a!save() to update the local variable. Swap their order and it should resolve the execution order.

    an alternative approach or recommended pattern in Appian

    Generally user can download a document in two cliks on form itself. For example, Show a fetch button, when user clicks on it query and retrieve the doc id using primary key and save in in a local variable. When this local variable is populated, show a link 'Download' (and hide the 'Fetch' button) which allows user to download file having documentDownloadLink in backend()

  • I have already attempted to change the order of the actions within the saveInto parameter, placing the a!save() before and after the a!startProcess() call. However, this did not resolve the issue. The local variable still gets updated only after the process execution is completed, rather than immediately when the link is clicked.

  • 0
    Certified Lead Developer
    in reply to vamshik254967

    Can you elaborate what the startProcess is doing actually? If you can call the query in a!save itself and get the document then what issue are you facing is enabling the documentDownloadLink with docId? I mean can the startProcess be skipped/removed entirey?

  • In this scenario, the a!startProcess() call is responsible for fetching the document. The process model invokes an SAP integration using the provided primary key, retrieves the corresponding document, and then returns the document back to the interface for download. Since the document retrieval depends on the SAP response, the process takes approximately 5–10 seconds to complete.

  • 0
    Certified Lead Developer
    in reply to vamshik254967

    Got it! 

    If changing the order of a!save and a!startprocess is not working, can you share a high level code structure with definition of local, banner field showWhen conditions as well as dynamic link saveInto in particular so as to help the current design better

  • 0
    Certified Lead Developer

    I suggest using a ButtonWidget() instead of a Rich Text Link for the part that will generate / retrieve the document - with ButtonWidget you simply set "loadingIndicator" to TRUE, and once clicked, the button will display the "spinning" animation until the process called is complete.  It doesn't exactly show a plaintext message like you said, but it sends the same message (and you can add mouseover text to the original button prompting the user to expect this).  After the loading is finished, you can then show a document download link i.e. right below the button containing the user's download.

  • Thank you, Mike Schmitt. This solution looks good and I appreciate the suggestion. Although it does not exactly align with my original requirement of displaying a banner message while the document is being fetched, using a `ButtonWidget()` with `loadingIndicator: true` appears to be a good alternative approach to provide user feedback during processing. If I am unable to achieve the expected behavior with the current implementation, I will definitely proceed with this approach.