Script Purpose

While the current rollup fields can display the minimum or maximum value of a set of linked record field, that functionality is limited. Rollups with min/max do not work for string based values, and they are also limited to displaying the value of the min/max field, not a different field from the linked record.

This script provides the ability to lookup the first or last record of a set of linked record when sorted by any field. It then outputs any field from the first/last linked record to a field in the original record that contained the links.

Script Notes

  • This script uses both of the helper functions that I created to make working with field values easier. The helper function that provides a hash table mapping record ids to field values helps performance when there are many records in the table holding the linked records.
  • The script runs the main function two times. Once to demonstrate outputting the same field that is used for the sort, and again to demonstrate outputting a different field from the one used for the sort. When adapting the script for your own use, you may want remove the code that has the script run a second time.
  • This script needs to be configured for your base. The configuration is stored in a scriptOptions variable. The first thing the script does is validate those options. If they are not valid, the script will throw an error.
  • When run, before making any data changes, the script tells the user what the script does, customized with the table and field names provided in the script options.
  • If a record has no linked records, or if all the linked records have null values, there is no first/last record and the output field will be blank.

 

Check out the original source to find an example base and video tutorial on this script.