Core FileMaker Blog

Keep up to date with CoreSolutions

Random Generator in FileMaker

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

Leave a comment

CoreSolutions Logo

London Office:
1-1615 N Routledge Park
London, ON N6H 5L6

Toronto Office:
2425 Matheson Blvd East
7th Floor
Mississauga, ON L4W 5K4

Toll Free: (800) 650-8882
London: (519) 641-7727
Toronto: (416) 410-8649
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.

SUBSCRIBE

Click the 'Subscribe' button to sign up for news & software tips.

Beyond Software

Copyright © 2018 CoreSolutions Software, Inc. All Rights Reserved