Question

Using Advanced Condition for validation with a For Each loop

  • 12 October 2023
  • 3 replies
  • 79 views

Badge +6

I have an extremely simple form that allows users to add lines to an editable list view. There are only two fields in each line. When the form submits I need to make sure they fill in both of the fields to submit. Have used advanced conditions with Else rules many times in the past. It appears that the way the If condition nests it doesnt allow an Else to be used to validate. So for instances if you have a For Each loop that does a Create Smart Object rule, it seems impossible to stop the user if they forget a field in the display row of the list with an IF advanced condition rule. Then you cannot use Else because of the way the rules nest. I have tried Form Validation but it behaves weirdly when trying to add more than one line of data to the view for submission. Any ideas? 

 

Thanks

 

Dave


3 replies

Userlevel 5
Badge +13

There are a couple of tricks to this - try using an additional unbound rule to do the validation of a particular row and set a flag that indicates whether the row is valid. This rule will be called in your loop and afterwards you would check the value of the flag. If it is false then you can stop rule processing/show message/whatever

Badge +6

So when you say “for a particular row” there would have to be a separate unbound rule for each row or the unbound rule would handle 1 through X rows?

I did try an unbound rule that would do validation when the form was in the Submitting state which did not work. I will experiment with other things

Thanks

Dave

Userlevel 5
Badge +13

Just one unbound rule that you would call from the for-each loop

Reply