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!
LVL 11
Andrew AngellCo-Owner / DeveloperAsked:
Who is Participating?
 
lesouefCommented:
on the 2rd set field line, set field (subst...) the field name is missing, so it applies to the current field, but none is active as there is no "goto field" before.
so just specify the field name there.
btw, you can combine the 2 Set field (invoices::authorizeneturl ) together:
set field (invoices::authorizeneturl ; substitute ("https://deal......." ; "#" ; "%23" ))
0
 
lesouefCommented:
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
0
 
lesouefCommented:
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" )
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Andrew AngellCo-Owner / DeveloperAuthor Commented:
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!?
0
 
Andrew AngellCo-Owner / DeveloperAuthor Commented:
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.
0
 
Andrew AngellCo-Owner / DeveloperAuthor Commented:
THANKS!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.