I recently built an interesting tool for a client, which was based on the requests for having layout after layout of different lists. Some examples were a list for clients and their addresses, another a similar list, except for the need for the phone number to be attached, and than even later on the need for the email address, all as separate lists. Of course the differences for the column structure were based on what found set the users were working with. I decided that, instead of building a new layout for each list they needed, I would build one layout that gave them the ability to select the columns they wanted displayed after a Find had been done.
The design is not as complicated as one might think. It requires very little in the ways of scripting, calculations, or layout design. In the example file (which is available to download at the end of the blog), I am working with a Contacts database. In this simple example, I use a list layout with drop downs in the header to select what the columns will display. To update the records I use a script trigger, which uses a replace field contents on the fields defined as Column 1, 2, and 3. The Header fields for selection are global fields with a value list of items to select from.
There are two ways to update the data in the columns. Either build Columns 1 – 3 as calculations, or use scripts to enter data. I chose to use a script to update the values, as they appear to update faster than calculations, and I won’t have issues with calculations loading while I scroll through the list. Let’s take a look at the scripts and the replace statements:
The script is straightforward, check the parameter and then based on which column ran the script, update the fields with a replace field contents:
For each column, the replace is similar based on what options are available. The nice thing about this process, although the example uses only same table data, I can have the script use related and calculated values as well. Even with calculated values, I won’t have to deal with slow load times while scrolling the list, as the data is stored in fields, rather than being calculated. As always stay tuned for more from your friendly neighborhood development group, and feel free to comment. Cheers!
**Edit – Having an issue with the upload of the example file, I will update as soon as possible.
***Edit, if you want the file to be Multi User friendly, use calculations instead. The function will be the Replace Field Contents Calculation defined above for each column.
About the Author
Prat joined MainSpring in March of 2008 as their application developer team lead. He’s responsible for helping clients develop custom, innovative solutions to better grow their business. He also provides guidance to other developers when needed. Prat enjoys fishing, traveling and playing basketball in his free time.