WebBrowserObject result: URL is malformed

In the Formula Panel, I have
https://maps.google.com/maps?q=”+arraystrip(replace(«Premises Street Address»+" “+«Premises City»+” “+«Prem State»+” “+«Prem Zip»,” “,”+"),"+")

In Data mode, the object has this error:
Web browser URL is malformed: “https://maps.google.com/maps?q=”+arraystrip(replace(3040 SE 143rd Ave+" “+Portland+” “+OR+” “+97236,” “,”+"),"+")

If I copy the formula to the Formula Workshop, I get this…
https://maps.google.com/maps?q=3040+SE+143rd+Ave+Portland+OR+97236

If I Right click on the Result in the Formula Workshop, and use the ‘Open URL’ option, it does open correctly as desired in my Browser.

Don’t you need the trailing quotes for the final URL in the formula. Try adding +{"} to your formula.

I want to make sure you are aware of the mapurl( function. I believe it does the same thing as your formula is trying to do. I think it would be simpler to use unless you are planning to advance beyond this to more complicated map URL’s.

I’m thinking that would be an unmatched quote and it does not fix it.

Yes, I did find the mapurl, and that does in fact work, but I was curious why the formula that I did create produced the error. I will be doing other mapping of locations that do not have addresses as well as some addresses that are not in the US.

I’m not sure why that error is happening for you. Panorama evaluates the formula to text, then passes that function to an Apple function called [NSURL URLWithString:]. If that function reports an error, then Panorama displays the malformed URL error. The internals of URLWithString are opaque to Panorama, so it cannot report any additional detail on what the problem is.

It could be that there are invisible characters that are being filtered out by the browser.

Here is the source code for the mapurl( function:

"http://maps.google.com/maps?q="+arraystrip(replace(address+" "+city+" "+state+" "+zip," ","+"),"+")

The only difference I see from your code is that it uses http instead of https, so maybe try that.

No change.

For me, it is all about learing to use the tool rather than getting my answer via mapurl(
I make the simple work, then make them more and more complex till my difficult stuff works.

To see if I could assist you, I followed these steps.

  • created a new database
  • created a new form
  • added a web browser to the form
  • copied your formula from the post above into the web browser
  • using copy/paste from your formula, created database fields
  • filled in an address from a neighborhood I am familiar with

Here is the result:

This is literally your formula, I did not edit it. As you can see, it works. So I am stumped, other than the possibility that your data contains something that NSURL doesn’t like.

I just realized I should try it with your data – that worked also.

After taking this second screen shot I realized I had left off the SE. I added that and it still worked, but I didn’t take another screen shot.

Robert sent me a copy of his database. The problem was he had the mode of the Web Browser object set to Literal, when it should have been Formula. Switching it to Formula fixed the problem.

His database had a second web browser object using the mapurl( function. That worked because he had set the mode to Formula.

I should have realized this from the first post, which clearly shows that the malformed “URL” contains the formula itself, not correct URL. I (and perhaps Robert) was thrown off a bit because when using literal mode, fields in « and » are substituted with the actual data from the field. But the formula itself is not evaluated unless you use formula mode.

There is extensive discussion of Literal vs. Formula mode on the Web Browser help page.

All of that seems simple. Except that I was aware of the Formula vs Literal options. I had flipped it back and forth between the 2 options several times in search of a fix. I failed to leave it in the formula mode when I sent it.
I have just now again flipped it to formula, hit the Apply button (just in case this was necessary), and yet still, I’ve bounced back & forth between Graphic & Data mode, Saved, and re-opened, yet the object continues to display the same error.

====

Bingo!!! What fixed it was my going to the Formula Panel and hitting return. None of the above triggered a change. Until I added a Return to the last line of the formula, the db did not accept that I had changed it. Only by adding that Return does it now work!

Thank goodness I had created a movie of my most recent playing. I’m not clear as to whether the adding of a Return triggered a recompile, or whether the compiler in that window wants the cursor below the last line of code.

My apologies, I see that there is a bug. It does not correctly prepare the formula when flipping between Literal and Formula mode. For now, if you flip the mode you have to also make a change to the formula (any change, even adding a space). Or you can close then re-open the form. For the future, I have added the one line of code needed to fix this problem.

1 Like