Skip to main content
June 5, 2021
Solved

Validation not refreshing when navigating interfaces

  • June 5, 2021
  • 20 replies
  • 0 views

Hello All,

I have an issue wherein my validationMessage is not removing after clicking cancel button. My scenario is I have a User Form that whenever I click submit it will show a message "All fields are required". After that I will now click the Cancel Button. However, when I go back to the Form my validation is still there. Can anyone explain to me how can I prevent that from happening?

Here's my validation

a!validationMessage(
message: "You must fill up both roles and email address!",
validateAfter: "SUBMIT",
showWhen: or(isnull(local!email), isnull(local!role))
)

Here's my field

a!textField(
label: "Email",
labelPosition: "ABOVE",
value: local!email,
saveInto: local!email,
refreshAfter: "UNFOCUS",
validations: {}
)

I put the validationMessage under the columnLayout.

Best answer by mikes0011

After any validation has been triggered for a particular instance of a form, it will stay triggered until the form is exited (like via a submit button click).  If you want your user to be able to press "cancel" and go back to a default state, you should have the cancel click submit from the current form and chain the user into a new instance of the same task - to the user this will happen seamlessly.

If the task in question is a start form, then it's a little trickier, but should still be possible - i.e. have the "cancel" button start the process then chain the user into a User Input Task that has the same interface set as its form.  Honestly though at this point you may as well ditch the Start Form setup and instead just have the process contain that task, and an XOR gateway could check what button was clicked and if it was "cancel", loop the user back to the same form again, otherwise move on in the process.

20 replies

stefanhelzle0001
Brainy
June 5, 2021

Please explain how you are doing this "back to the form" and "click the cancel button" interaction. My any chance, could it be that you embed this as a sub interface into another one?

With proper usage of related actions or startProcessLink this does not happen.

June 5, 2021

Hello, thank you for answering.

Yes, it's just a sub interface. The way I navigate is by declaring rule input called action. I have a dashboard called "user management" and then I have "user registration", there is a button under user management called Create User, whenever I clicked that I used the showWhen. I'll show the user management if the value of ri!action is userManagement and show user form if the value is "addform" that's how I navigate interfaces.

June 7, 2021

Hello, still not resolve 

mikes0011
mikes0011Answer
Brainy
June 7, 2021

After any validation has been triggered for a particular instance of a form, it will stay triggered until the form is exited (like via a submit button click).  If you want your user to be able to press "cancel" and go back to a default state, you should have the cancel click submit from the current form and chain the user into a new instance of the same task - to the user this will happen seamlessly.

If the task in question is a start form, then it's a little trickier, but should still be possible - i.e. have the "cancel" button start the process then chain the user into a User Input Task that has the same interface set as its form.  Honestly though at this point you may as well ditch the Start Form setup and instead just have the process contain that task, and an XOR gateway could check what button was clicked and if it was "cancel", loop the user back to the same form again, otherwise move on in the process.

The Expression Guru
June 7, 2021

Hello, sorry I'm not using any process model for navigating interfaces.

So you're saying I need to create a process model to do that? 

vamsik0002
June 7, 2021

If you are not submitting the form on cancel button, then you can try this

a!localVariables(
  local!amount,
  local!buttonValue,
  local!showWhen:and(local!buttonValue,isnull(local!amount)),
  a!formLayout(
    contents: {
      a!textField(
        label: "Amount",
        value: local!amount,
        saveInto: local!amount
      )
    },
    buttons: {
      a!buttonArrayLayout(
        buttons: {
          a!buttonWidget(
            label: "Submit",
            style: "PRIMARY",
            submit: true,
            saveInto: {
              a!save(local!buttonValue,true)
            }
          ),
          a!buttonWidget(
            label: "cancel",
            saveInto: {
              a!save(local!buttonValue,false)
            }
          )
        }
      )
    },
    validations: a!validationMessage(
      message: "Is required",
      validateAfter: "SUBMIT",
      showWhen: local!showWhen
    )
  )
)

June 7, 2021

Hello, Thank you for your response. However, I already tried it changing the showWhen value to false when I click cancel. However, when I go back to userRegistration form the validation will be removed. But when I add ri!ShowWhen then change it back to true after clicking the "Create User" button the validation is still there.

vamsik0002
June 7, 2021

You are using same showWhen parameter for "Create User" button and "Submit" button?