Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

How to use instanceManager.count to identify first and last row of a repeatable subform

dv27
Level 2
Level 2

How can I identify the first and last row in a repeatable subform? I’m using instanceManager and managed to calculate the total number of rows using FormCalc, however, I don’t know how to identify the first and last row.

This is what I need to do:

The repeatable subform contains a checkbox. If this checkbox is checked in the first and/or last row (of the repeatable subform), then I need a calculation to be performed, otherwise, this calculation should not occur.

Thanks for your help!

2 Replies
radzmar
Level 10
Level 10

Hi,

the first row always has the instance number 0, such as "Table1.Row1[0]" or simply "Table1.Row1".

The last row can be addressed by instance counter "Table1.Row1[Table1.Row1.instanceManager.count - 1]" or the short way "Table1.Row1[Table1._Row1.count - 1]".

dv27
Level 2
Level 2

hello there! thank you so much!!!! However, I’m trying to apply this same code to a second object that is performing an additional calculation and I’m having A LOT of trouble and would LOVE your help or anyone else's help.

My calculations are dependent on:
1.      If a checkbox is checked
2.      The number of days entered
3.      The number of rows that are added

Basically, if the first row is the ONLY row, then it can contain three possible calculations

  1. if a checkbox is checked and the total number of days entered is <= 2, then the calculation is.... partial.rawValue  * Days.rawValue
  2. if a checkbox is checked and the total number of days entered is > 2, then the calculation is....perDiem.rawValue * (Days.rawValue - 2 ) + (partial.rawValue * 2)
  3. otherwise, the calcuation is....perDiem.rawValue * Days.rawValue

    However, if more than one row is selected, then the first and the last row would contain the following possible calculations:

    1. If a checkbox is checked, then the calculation is…perDiem.rawValue * (Days.rawValue - 1 ) + partial.rawValue
    2. Otherwise, the calculation is…perDiem.rawValue * Days.rawValue

      The middle rows are always going to contain one possible calculation of…perDiem.rawValue * Days.rawValue