Automation using Script to search for related records, find highest number, input into field

We use a form with our database so that students can post pictures of homework. When completing the form, each student inputs her student ID to create a new record, and attaches pictures of homework. The homework is associated with a specific session. The master table of students and sessions includes a unique “student session id”, but students don’t know it (ie can’t input it into the record). I would like to create an automation that is triggered when a student submits a record to the homework table. The automation would look for all of the “student session IDs” associated with that student ID, find the largest “student session ID” for that student (more recent = highest number), and input it into a field in the record. Can anyone point me to a script that would do something like this?
Thanks!

Welcome to the community, @Hilary_Sonstegard!

@Kamille_Parks discusses how to do this at length in last week’s BuiltOnAir podcast:

1 Like

I’m more of a visual person. Does anyone have code that I could look at, even if it’s not exactly what I’m looking for?

That is a video podcast.