4

Question

Is it possible to make a field required dynamically depending on another field's selected value?

Acceptance Criteria

If a user selects "Sales" from the department dropdown menu, make the field "department number" required

Attempted but failed I tried creating a formula for the selected value and I placed the formula variable in the required field of "department number" but it did not do anything.

1 Answer 1

7

Two main approaches come to mind:

1) Set up conditional visibility

  • Including two instances of the second input component in the screen
  • Making one required, and the other optional
  • Setting up conditional visibility on them so that only one is displayed at a time (based on whether or not it should be required)
  • You could use decision and assignment elements after the screen to store the selected value in a variable so you don't have to duplicate your create/update/get elements

2) Validate users’ inputs with flow formulas

  • Functionality only available on certain input components (eg. Text)
  • Has been quite buggy in my experience
  • If the user leaves the field blank, and the field is not required, the flow doesn’t validate.

Other approaches include setting up a decision element to check value of second field and returning to screen + displaying error if it's blank, or building a LWC for the two fields in question and embedding it in the screen. The first two are much better options though.

1
  • Great, your first suggestion helped me achieve my goal. Thank you very much.
    – Nino Y
    Commented Jan 6, 2020 at 5:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .