Simple way to validate each row in a list view on a form

  • 28 October 2017
  • 1 reply
  • 47 views

Badge +7

If you are like me you looked all through articles on validating list rows and found some very complicated validation rules that were very hard, actually impossible to put on my submit button. The "for each" and validation rules just did not work

 

My form had 4 separate complex lists and item data as well. Each list had different rules

 

List 1 had yes
o questions and filled in a result column with data only when complete. This list had to have at least 1 row that was valid and every row had to have a value in the result column.

 

List two just needed at least one row with one column of data all other columns were not required,

 

List 3 had a bunch of calculations that resulted in values the total of which had to match another part of the form. So the final collume would be greater than zero.

 

List 4 had to have data in two columns but it was impossible to have data in one and not the other because it went to a sub view that forced that with the save rules

 

I only describe the lists because you need to be able to create an If expression that covers the rule.

Steps

Add a hidden column to your list called RowValid. In this column add an expression, this is where that if expression will go and the results of your IF expression  will be true=1 false =0.

 

On your view create 3 data labels (hide them once you test) and use these expressions

 

Rowcount data label (expression)- List Count ( a control taken from the "Add/Edit row")

rowSum data lable (expression) - List Sum ( Validrow Data Label )

Viewvalid (expression) - If ( ( rowcountData Label > 0 ) And ( rowcountData Label = rowsumData Label1 ) , Valid, NotValid )

 

The logic

Rowcount is greater than zero so at least one row. Also if the row is valid the rowvalid column will equal 1 so if all rows are valid the row count equals the sum of the RowValid column. The result is either valid or invalid which is easy to check for on the submit button rule.

 

Now in your submit button rule you add an advanced condition

Table1 ViewValid Data label <> valid

Or

Table2 ViewValid Data label <> valid

Or

Table3 ViewValid Data label <> valid

Or

Table4 ViewValid Data label <> valid

 

Then Show a message (tell them what is wrong, go look at the tables)

End the rule (you don’t want it to continue and match something else)

 

A lot of words but very simple to do.

 

I hope this helps someone

 

 


1 reply

Badge +9

Thank you for sharing the information.


 


Kallie

Reply