AnsweredAssumed Answered

Script working on FMP but not FmGo

Question asked by user2148443 on Feb 6, 2019
Latest reply on Feb 6, 2019 by user2148443

I have a script i am using to get distance between 2 locations (Thanks Hi-Voltage). It work perferly via FmPro as desktop.

However when i run it on an iPad in FMgo it Fails and provides the "Could not connect to Google Maps." message.

Unfortunately, i haven't figured a way to debug using an ipad, to find out exactly what is going wrong.

 

 

Set Error Capture [ On ]

Allow User Abort [ Off ]

#

# ------------------------------------

# set parameters [MODIFY THIS SECTION]

# ------------------------------------

Set Variable [ $APIKey ; Value: $$googleAPIkey ]

Set Variable [ $Mode ; Value: TO_001____PREFERENCES::TransportMode_Global ]

Set Variable [ $Units ; Value: TO_001____PREFERENCES::DistanceUnits_Global ]

Set Variable [ $Avoid ; Value: TO_001____PREFERENCES::Avoid_Global ]

#

# ------------------------------------

# query google

# ------------------------------------

Set Variable [ $URL ; Value: Let( [     o = Substitute ( $$Origin ; [" " ; "+"]; ["¶"; "+"]; ["|"; "+"] );     d = Substitute ( $$Destination ; [" " ; "+"]; ["¶"; "+"]; ["|"; "+"] );     m = Case($Mode <> ""; "&mode=" & Lower ( $Mode ));     a = Case($Avoid <> ""; "&avoid=" & Subst… ]

Insert from URL [ Verify SSL Certificates ; Select ; With dialog: Off ; $Source ; $URL ]

#

# get error results from json data

Set Variable [ $ErrorMessage ; Value: JSONGetElement ( $Source ; "error_message") ]

Set Variable [ $Status ; Value: JSONGetElement ( $Source ; "rows[].elements[].status") ]

#

# ------------------------------------

# validate response

# ------------------------------------

If [ $Source = "" ]

# no source returned - timed out

Show Custom Dialog [ "Message" ; "Could not connect to Google Maps." ]

#

Else If [ $ErrorMessage <> "" ]

# API returned an error

Show Custom Dialog [ "Message" ; $ErrorMessage ]

#

Else If [ $Status = "ZERO_RESULTS" ]

# no results found, origin or destination do not exist

Show Custom Dialog [ "Message" ; "Origin or destination address not found." ]

#

Else If [ $Status = "NOT_FOUND" ]

# no route found

Show Custom Dialog [ "Message" ; "Route not found." ]

End If

#

# ------------------------------------

# get results

# ------------------------------------

Set Variable [ $$ResultDuration ; Value: Let (    dur = JSONGetElement ( $Source ; "rows[].elements[].duration.value" );    GetAsTime(Round((dur/60); 0) * 60) + 0   ) ]

#

# ------------------------------------

# set results [MODIFY THIS SECTION]

# ------------------------------------

Set Field [ Events::TravelTime ; $$ResultDuration ]

#

 

 

Any ideas what might cause it?

Happy to share access to the server if someone wants to have a look.

Outcomes