Brian Dunning's FileMaker Custom Functions

GetListParameter ( ParameterList ; ParameterName )

Extract a value by name from any list

  Average rating: 3.9 (35 votes) Log in to vote

Will Loving   Will Loving - Show more from this author
Dedication Technologies, Inc.
http://studioschoolpro.com

Share on Facebook Share on Twitter

  Sample input:
GetListParameter( $GiftList ; "GiftType" )

[ Where $GiftList = "ContactID=1234¶Amt=100¶Date=7/21/2018¶GiftType=Cash" ]
  Sample output:
Cash

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This is a variation on Daniel Kaan's excellent GetParameter() function. Daniel's function allows parameter to be extracted by name from a ScriptParameter. This variation allows you to extract a parameter value by name from ANY list, be it a $ variable of field value.

Update 2017-Nov-20: Added & "=" to linestart parameter in order to handle parameters that may contain other parameters, e.g. "version" and "version_developer" (Thanks, Stephen).

I use this most often when I want to pass along a group of values to from one layout to another, usually for the creation of a related record. Why not just set a key field and pull the values through a relationship? Because using SetField with local parameters is much faster than pulling values through a relationship, especially over a WAN.

Example: An online donation has resulted in a record created in WebDonation. The FM user has matched the donor to an existing Contact record and now wants to add a related record for the Gift to the Contact record. I create a parameter called $DonationInfo as follows:

List(
"ContactID=" & Contact::ContactID
"WebDonationID=" & WebDonation::WebDonationID ;
"Amount=" & WebDonation::Amount ;
"Date=" & WebDonation::GiftPledgeDate ;
"GiftType=" & WebDonation::GiftType
)

Switching to the Donation table layout, I create a new record and then:

SetField [ Donation::WebDonationID ; GetListParameter ( $DonationInfo ; "WebDonationID" ) ]
SetField [ Donation::ContactID ; GetListParameter ( $DonationInfo ; "ContactID" ) ]
SetField [ Donation::Amount ; GetListParameter ( $DonationInfo ; "Amount" ) ]
SetField [ Donation::Date ; GetListParameter ( $DonationInfo ; "Date" ) ]
SetField [ Donation::GiftType ; GetListParameter ( $DonationInfo ; "GiftType" ) ]

The beauty of this method is that the order of the parameters is irrelevant and new parameters can be added at any point. (This also true of the original GetParameter function).

One caveat: If your list references text fields that contain carriage returns, you will need to Substitute() another character such as Pipe "|" for the CRs when declaring the list. Then, when doing the SetField for the parameter, Substitute again to replace the pipes with CRs.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: