Link to home
Start Free TrialLog in
Avatar of Andrew Angell
Andrew AngellFlag for United States of America

asked on

Filemaker not correctly URL encoding this field...???

I'm a web developer and I've got a client using Filemaker.  I've created a small script for them which charges credit cards with authorize.net using data supplied from the current invoice they're looking at when they click a "charge card" button within Filemaker.  A URL is created using data from the invoice as querystring values.  The problem is, it isn't correctly URL encoding the string.  It's getting spaces correct, using %20 for spaces.  The only problem I've run into is with # signs. It should put %23 for a # sign in a URL encoded string, but it's not, it's just leaving the # sign as is.  This being the case, the web browser sees this as an anchor and stops reading the querystring values, so I can't use the values beyond the # sign in my script.

Any information on how I can make Filemaker handle #'s correctly when sending to a URL would be greatly appreciated.  Thanks!
Avatar of Member_2_908359
Member_2_908359
Flag of France image

fm does not encode anything in URL's except spaces; it's up to you to do it.
but that's no great deal if you know which characters you'll use.
Just use the subst function on the field or variable containing the URL to swap forbiddent characters with the right % ascii code.
example:
Substitute ( table::url ; "#" ; "%23" )
if you have several records where you'd like to do this, you can use the replace function which does it on a found set of records
if you have several characters to replace, you can embed the replacement like this instead of executing the subst function several times:
Substitute ( Substitute (table::url;"é"; "é" ); "#"; "%23" )
Avatar of Andrew Angell

ASKER

Ok, well I found the substitute function in the list within the Script Maker, but I'm getting a message saying it can't find the specified table for some reason, even though I'm selecting it right from the list it gives me in the Script Maker.  The file is called Invoices.fp8 and the field the URL is being held in is AuthorizeNetURL.  When I double click the Sub. function in Script Maker it writes out the syntax for me, which matches what you show.  ( ie. Substitute ( text ; searchString ; replaceString ) ).  I replace text here with Invoices::AuthorizeNetURL and I end up with:

Substitute (Invoices::AuthorizeNetURL; #; %23)

When I click OK, though, I get the following message:

The specified table cannot be found.

What's going on here!?
Ok, I was missing the quotes around the strings to replace, that was the problem there.  I'm still having issues, though...it simply didn't change the outcome.  Here's a screen shot of the way I have the filemaker script setup now...

http://www.dealsdirectinc.com/temp/script.jpg

So, it's suppose to set the AuthorizeNetURL field to the URL that is to get sent to my script based on data in FM.  This works great.  Right after that it's suppose to replace any # signs with %23 so that it's correctly URL encoded when sent to the browser.  Then, it uses Open URL to open the URL using the value of AuthorizeNetURL.

What happens when I run this is exactly the same as before I added the Substitute thing...it sends the URL with a # sign so when the browser hits that it sees an anchor and stops.  So it seems that my Substitute thing isn't working.  When I look in the browser address bar it's still got a # instead of %23.
ASKER CERTIFIED SOLUTION
Avatar of Member_2_908359
Member_2_908359
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
THANKS!!!