CKonash Posted March 23, 2019 Posted March 23, 2019 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
comment Posted March 23, 2019 Posted March 23, 2019 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.
CKonash Posted March 23, 2019 Author Posted March 23, 2019 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
comment Posted March 23, 2019 Posted March 23, 2019 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 ] 1
CKonash Posted March 23, 2019 Author Posted March 23, 2019 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
LaRetta Posted March 24, 2019 Posted March 24, 2019 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. 🙂
Steve Martino Posted March 24, 2019 Posted March 24, 2019 It's also being used in the GetValue expression to pull the proper value in each loop iteration. 1
Recommended Posts
This topic is 2069 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now