I’m working on an Appian Portal where clients fill out survey details. Requirement: if a user tries to Alt+Tab, refresh, close the browser, or navigate away without saving, we want to show a warning message so they don’t lose entered data.
Has anyone implemented this before? I’m currently tracking unsaved changes with a local flag, and I’m exploring using a!webContentField() to inject JavaScript (beforeunload event) to display the browser’s native confirmation prompt.
a!webContentField()
beforeunload
Looking for best practices or recommendations on:
Reliable way to trigger warnings in Portals.
Discussion posts and replies are publicly visible
As far as I know there's no such functionality (and no plausible way to do so) for alt-tabbing (i.e. just switching windows); though since regular Appian tasks do warn a user about losing data if they attempt to close the task / close the tab / close the browser before saving/submitting, I do agree that these items are something Appian could potentially track as a future enhancement to Portal forms.
I think one of the technical caveats currently might be, since regular tasks only trigger the "save warning" when data is in the Rule Inputs, that (by itself) might not work for Portal forms since there aren't rule inputs mapping to ACP variables as such - meaning, if i'm right, that if they wanted to implement this they'd need to concoct a novel way to have the form maintain awareness of its unsaved data. But i would guess (being otherwise fuzzy on the back-end mechanics anyway) that it might be possible, if burdensome, to implement.
I would suggest you raise a use case with Appian for this, it seems like it could be a common (and generally-applicable) use case, which is one of the best things (IMHO) to make feature requests over.
Does your trick with the web content field work?
No, that trick with the web content field doesn’t work. Suggest to add the JavaScript update in the portal package
You will have to open a support case to propose a product enhancement to get this into the platform.