GetListParameter ( ParameterList ; ParameterName )
Rate this function: Average rating: 3.0 (13 votes) Discuss this Custom Function
Will Loving, Dedication Technologies, Inc.
http://dedicationtechnologies.com
Extract a value by name from any list
Sample Input:
| GetListParameter( $SomeList ; "SomeParameter" ) |
|
Sample Output:
|
Description:
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.
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.
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:
|
Newest Custom Functions:
| 1. |
phpArrayValue ( array ; key ; pos ) |
| |
(Fri, Jan 27, 1:49pm) |
| 2. |
solfm_timeToMinutes (theTime;roundSec) |
| |
(Fri, Jan 20, 6:26am) |
| 3. |
filterLines(filterField;filterValue;Result) |
| |
(Sat, Jan 14, 2:20pm) |
| 4. |
getMaxValue ( theList ) |
| |
(Thu, Jan 12, 1:06pm) |
| 5. |
MiddleWordsIncPunct ( text ; startingWord ; numberOfWords ) |
| |
(Sat, Jan 07, 9:16am) |
| 6. |
WindowInfo |
| |
(Fri, Jan 06, 12:39pm) |
| 7. |
CenterWindow in Window vert horiz (demension) |
| |
(Fri, Jan 06, 12:25pm) |
| 8. |
UTF8_to_TXT ( Text , Platform ) |
| |
(Wed, Dec 28, 10:44pm) |
 |
|