Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Looping help for attendance records

Featured Replies

Hello,   

I have a dozen fire departments that manage attendance records (related to an event) and they enter them by barcode scanning or manually selecting their name (ID) from a dropdown and clicking an Add button.  I have been asked a few times for them to be able to add all members to the event attendance portal.  I'm not too sure how to approach this.  

The members and their ID's live in the Personnel Record Table, The attendance records are created in the Attendance Table when someone is checked in.  What is a good way for me to capture all the firefighters ID's in the personnel records table (or loop through the records) and then create new attendance records with all of those firefighters ID's?   

Should I create two open windows, one in personnel records and one in attendance,  capture the firefighter ID's one by one after I perform a find of all firefighters in that fire company and then go to the attendance window and create a new record with the captured variables for that event and the firefighter ID, then go back to the personnel window and get a new personnel ID.  

Just wondering if there is a logical way to approach this.  

 

Thank you in advance for even looking at this.  

Chris

If you have an identifier such as the fire company, you could use it to define a relationship to the Personnel table. This would enable you to get all the relevant PersonnelIDs at once using the List() function. Alternatively, you could find the relevant personnel and import them into the Attendance table, then populate the EventID using Replace Field Contents.

  • Author

Thank you very much Comment.  The first method seems the best for me and I think I can figure out the steps to do that.  

One question, how do I then use that returned data in the List() function to create individual records in the attendance table?  My apologies for not fully understanding your initial directions.  

Thanks,

Chris

Roughly: 

Set Variable [ $eventID; Events::EventID ]
Set Variable [ $personIDs; List ( Personnel::PersonID ) ]
Freeze Window
Go to Layout [ Attendance ]
Loop
    Set Variable [ $i; $i + 1 ]
    Exit Loop If [ $i > ValueCount ( $personIDs ) ]
    New Record  
    Set Field [ Attendance::EventID; $eventID ]
    Set Field [ Attendance::PersonID; GetValue ( $personIDs ; $i )  ]
End Loop
Go to Layout [ original layout ]

 

  • Author

Wow.  that was so perfect.  I'm not sure what the $i of the script does but I followed along and everything works perfectly.  I tried to get my own iterations of a script to work for months now and you just solved it in one day.  I can't thank you enough!  

Thank you!!  Have a great weekend! 

Chris

 

18 hours ago, CKonash said:

I'm not sure what the $i of the script does...

Hi Chris,

The $i variable is a counter which increases with each loop.  When first entering the loop, it sets $i = $i + 1 but because it is starting, the $i will be empty so its value will be 1.  Each time it loops to that point again, it will test if it is greater than the value count of the list.  If yes, it will exit but if not, it will again increment by 1.  It is a cool counter technique.

The first two steps inside the loop (the first which sets the $i and the second which tests) can also be written as a single step:

Let ( 
$i = $i + 1 // increment the counter 
;
$i > ValueCount ( theList ) // and then boolean test if the loop should exit
)

In addition, if you are using a counter in multiple loops, it can be useful to clear the $i so it does not conflict with its use in the next loop.  It too can be a separate step (after you exit the first loop) or written all as one within the Exit Loop[] as:

Exit Loop If [ Let( $i = $i + 1 ; If ( $i > ValueCount ( theList ) ; Let ( $i = "" ; True ) ) ) ]

All methods are great; use the one easiest for you.  🙂

It's also being used in the GetValue expression to pull the proper value in each loop iteration.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.