For Each Loop of Rows in a List View

  • 8 December 2015
  • 8 replies
  • 72 views

Badge +7

I had a scenario where data needed to be passed from each row of a list view somewhere  and perform an operation.

 

It took me a while to figure this out, so I will share this. In this simplified example I will show a message for each row of a list view.

 

 

 

 

 

To begin, add a rule to the list view add "For each item in a List View" Condition

 

 

14516i42FAC837B2E32774.png

 

 

 

 

 

12459i430110EC70509A45.png

 

 

Select All rows 

 

 

 

 

 

10838i63477B638F489138.png

 

 

Then click (configure)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The first few times I attempted this I was transferring the data label from the Display Row(s)

 

 

 

 

 

11698i1EE777D24A0CAE53.png

 

 

This is WRONG!

 

 

 

 

 

15411i8217C2836D84EF92.png

 

 

Nothing shows up. 

 

 

 

 

 

 

 

 

But instead transfer the data from the SmartObject. 

 

 

 

 

 

11922i0653A13DA1A29332.png

 

 

When you transfer the data from the SmartObject it transfers one row at a time. 

 

 

 

 

 

And the data show up where it is sent!

 

 

13524iF6B49D8633762D89.png

 

 

14753iF8A26E11E459CAD1.png

 

 

11465iD5EAA0E5298A1419.png

 

 

 

 

 

 

 


8 replies

Badge +4

Hi Chadg,

 

This is great explaination for sure.

 

On top of what you have explained in the post, is there any way by which we can concat all the values which you showed in message box. e.g. rather than showing one by one as the loop runs, i need to show the concatenated value at once after the For each construct.

 

Is there any way to do that?

 

Regards

Gaurav Mehta

Userlevel 3
Badge +10

@GauravMehta Create a parameter on the form, replace the Show A Message action with a Transfer Data action, transferring [yourParameter][SmartObject Reference Field] into the yourParameter parameter field.  Then, outside of the loop, Show A Message passing in yourParameter.

Something to be aware of...  The 'for each' loop will only loop through list view items that appear on the current page (if you have paging enabled). 

Hoping someone can help with a slightly more complex version of this:

 

Wanting to...

SMO populates a list view with a number of rows.

Click a 'Process Now' button which starts following (ideal) rule:

  1. First row of list view is put into an item view
  2. Two fields in item view are in editable mode, each with own 'Update' button e.g. telephone numbers
  3. Telephone number fields are validated - if incorrect pattern, conditional style to red
  4. (Ideally will validate that number shown is in one of TWO patterns (XX) XXXX XXXX (fixed line) or XXXX-XXXXXX (mobile) or can also be blank)
  5. User can change the number to either one of the correct patterns (depending of fixed or mobile) then click 'Update' button on each to save
  6. When done for that particular record, user clicks a 'Next' button to populate the item view with data from the next row of the List View.
  7. User continues editing and clicking 'Next' until all the rows have been processed.

 

It is almost like a 'For ALL Rows on a List View pause and await user interaction'-type rule.

 

Any ideas?

 

Cheers

 

Badge +10

I learned it hard way as well.

 

Any idea why we cannot use control itself and we have to use columns from SMO?

Userlevel 3
Badge +10

@K2_Beginner: Only the SmartObject reference fields can be seen in the context of a specific iteration of a loop.  The controls themselves don't change, but the value of the SmartObject field in those controls changes for each row the rule loops through.

Badge +1

This is great but i would like to store value of each item selected in list view in a parameter or data label control. How do we do that?

Badge +10

Thanks Jonathan


@JonathanT wrote:

@K2_Beginner: Only the SmartObject reference fields can be seen in the context of a specific iteration of a loop.  The controls themselves don't change, but the value of the SmartObject field in those controls changes for each row the rule loops through.


 

Reply