Random Generator in FileMaker

Random Generator in FileMaker

Keep up to date with CoreSolutions

Random Generator in FileMaker

Random generation in FileMaker title image

I recently designed a small database for an office event. The event required 5 teams, and I wanted the teams to be randomly chosen. To perform a simple random selection I had a “Go To Record/Request/Page” with a calculation of “Round(Random*Get(FoundCount);0)”. This will choose a random whole number from 0 to the found count and go to that record.

The design was to have a single button to select the random employee from a table I created with all our employees and place them on the next team. After an employee is selected, that employee should not be able to be selected again. Firstly to add the employee to the next team a global variable was created with the first team. The first employee chosen would have that team in a field, and then the script would update the global to the next team for the next selection. Secondly to solve the issue of an employee being selected once, I set a Boolean in the employee table for each record if they had been chosen. The find would check that variable and only return the employees not already on a team.

In order for the UI to show the employees on each team I created 5 relationships for each team based on the employees tables team field and a defaults table with the 5 constants for each team. On the UI itself I have 5 portals based on the 5 different relationships.

A couple of quick tips, as Evan pointed out in an early blog, ensure that the defaults table has a record, if not the constants and relationships will not work. Also add an if statement to test for when found count is 0, and either display a message that everyone has been picked if using the button single selection method, or an exit script if a loop method is performed.

Team generation trees

Comments

Leave a Comment