GetListParameter ( ParameterList ; ParameterName )
Extract a value by name from any list
Average rating: 3.9 (35 votes) Log in to vote
Will Loving - Show more from this author
Dedication Technologies, Inc. http://studioschoolpro.com |
[ Where $GiftList = "ContactID=1234¶Amt=100¶Date=7/21/2018¶GiftType=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
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.