Brian Dunning's FileMaker Custom Functions

GetQueryStringValue ( keyName ; sourceUrl )

Given a full URL and name of a key, returns the given key's value out of the entire URL.

  Average rating: 4.4 (25 votes) Log in to vote

Cristos Lianides-Chin   Cristos Lianides-Chin - Show more from this author
Anchor-Buoy Software, LLC
http://www.anchorbuoysoftware.com

Share on Facebook Share on Twitter

  Sample input:
GetQueryStringValue ( "reqid" ; "https://example.com/support.php?pg=request&reqid=38842" )
  Sample output:
38842

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

UPDATED 2014-09-03 with better version from commenter "unix" from Japan.

When given a full URL (including a querystring), and the name of a specific key in that querystring, this function will return the value associated with that key. Especially useful in conjunction with the GetLayoutObjectAttribute( "webviewerName" ; "Source" ) function, which can get the URL of a page to which the user has navigated.

 

Comments

unix   unix, Japan
Sep 2, 2014
Let ([
~key = keyName ;
~url = sourceUrl ;

~params = Replace ( ~url ; 1 ; Position ( ~url & "?" ; "?" ; 1 ; 1 ) ; "" ) ; //get after "?"
~params = Left ( ~params ; Position ( ~params & "#" ; "#" ; 1 ; 1 ) - 1 ) ; //get before "#"
~params = ¶ & Substitute ( ~params ; "&" ; ¶ ) ; //separate key=value with ¶
~pos = Position ( ~params ; ¶ & ~key & "=" ; 1 ; 1 )
] ;
Case ( ~pos ; GetValue ( Substitute ( Replace ( ~params ; 1 ; ~pos ; "" ) ; "=" ; ¶ ) ; 2 ) )
)
 

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 15 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:

Under construction. Email me your wish list for improvements.