Page 1 of 1

Error opening complex URLs in Contacts using Open URL script

PostPosted: Tue Jan 12, 2010 8:34 am
by charliecheney
Hi there. I've noticed that trying to open a complex URL using the Open URL script in SeedCode complete is not working once it hits the "SeedCode_GetScriptParameter" custom function. I think it's because there's an equal sign in the URL:

Here's a sample URL I'm trying to open... but nothing happens. I believe the the custom function leaves the "$Address" variable empty:
http://www.facebook.com/profile.php?id=1170694181

What's the best way to get around this? Thanks. -Charlie

Here's the "SeedCode_GetScriptParameter" custom function:

Let ( [
string = Substitute ( Get ( ScriptParameter ) ; [ "\"" ; "^^" ] ; [ " ;" ; ";" ] ; [ ";" ; "\" ;" ] ; [ "= " ; "=" ] ; ["=" ; " = \"" ] ; ["¶" ; "~~" ] ) & "\"" ;
eval = Evaluate ( "Let ( [" &  string  & "] ;" & Name & " )" ) ;
result = Substitute ( eval ; [ "^^" ; "\"" ] ; [ "~~" ; "¶" ] )
] ;

If ( result ="?" ; "" ; result )

)

PostPosted: Wed Jan 13, 2010 12:24 pm
by John Sindelar
I think the following will teach it to accept an equal sign in the param itself:

Let ( [
string = Substitute ( Get ( ScriptParameter ) ; [ "=" ; "!!!!" ] ; [ "\"" ; "^^" ] ; [ " ;" ; ";" ] ; [ ";" ; "\" ;" ] ; [ "= " ; "=" ] ; ["=" ; " = \"" ] ; ["¶" ; "~~" ] ) & "\"" ;
eval = Evaluate ( "Let ( [" & string & "] ;" & Name & " )" ) ;
result = Substitute ( eval ; [ "!!!!" ; "=" ] ; [ "^^" ; "\"" ] ; [ "~~" ; "¶" ] )
] ;

If ( result ="?" ; "" ; result )

)

Patch seems to break a few other things

PostPosted: Wed Jan 13, 2010 12:31 pm
by charliecheney
That appears to break some other interface navigational elements... the List/Detail/Table buttons didn't work anymore once I changed the custom function.

:(

PostPosted: Wed Jan 13, 2010 12:34 pm
by John Sindelar
Ah, we probably use !!!! as a delimiter in those. Replace !!!! in the custom function with _!_!_!_!

(did the url work?)

PostPosted: Thu Jan 14, 2010 12:08 pm
by charliecheney
Well, I may be doing it wrong, but when I changed it it didn't work either.

The detail/list/table buttons did not work and the url didn't launch.

PostPosted: Thu Jan 14, 2010 12:14 pm
by John Sindelar
ACK! I'm so sorry Charlie; I was not thinking clearly when I sent this. There is no way we can map the = sign in the parameter. BUT we can translate it at the end. So if you change the "=" in your url to _!_!_!_! the following function will turn that into a "=" when it's all done:

Let ( [
string = Substitute ( Get ( ScriptParameter ) ; [ "\"" ; "^^" ] ; [ " ;" ; ";" ] ; [ ";" ; "\" ;" ] ; [ "= " ; "=" ] ; ["=" ; " = \"" ] ; ["¶" ; "~~" ] ) & "\"" ;
eval = Evaluate ( "Let ( [" & string & "] ;" & Name & " )" ) ;
result = Substitute ( eval ; [ "_!_!_!_!" ; "=" ] ; [ "^^" ; "\"" ] ; [ "~~" ; "¶" ] )
] ;

If ( result ="?" ; "" ; result )

)

PostPosted: Thu Jan 14, 2010 12:41 pm
by charliecheney
So, just so I have this straight here...

The first step in the script (currently) is
Set Variable [$Address; Value:SeedCode_GetScriptParameter ("Address")]

You're instructing me to:
Capture that "Address" beforehand in another variable, substitute the "=" sign in that string with _!_!_!_!, then re-insert the "=" sign later, and reset the "$Address" variable to the original string before I send it to the Open URL step?

I think I understand that. :-)

*********************

While I'm here, I see in the ERD you have MailingMembers linked to Appointments... but I don't see any interface layouts to link the two together in the UI so that the merge tokens you've set up will grab data from the Appointment itself. Is there a mini-window (or something) somewhere that I've missed that links Appointments to Mailings?

Thanks again for your tremendous support, you're amazing. -Charlie

Perhaps easier way...

PostPosted: Thu Jan 14, 2010 1:24 pm
by charliecheney
I worked out a different way. I trapped for the value string before the SeedCode GetScriptParameter custom function is called. If it's a URL I just have it OpenURL without calling the custom function.