AnsweredAssumed Answered

How do I get records from a portal into script array

Question asked by user2148443 on Dec 6, 2018
Latest reply on Dec 8, 2018 by user2148443

I am trying to get all the addresses i have showing in a portal to display in a map.

 

 

This is the Script which generates the array. but not sure how to modify it to get the data from the portal. As obtained the code from David Weiner's project "Google mapping module", which works fine for a found set of records. However, for what i am trying to do is script it to create the array fro the portal records as this is filter by a date for when bookings are due.

 

Go to Record/Request/Page [ First ]

#

# now loop through and set up a new array of coordinates

Loop

Set Variable [ $n ; Value: $n + 1 ]

#

#

# ========== replace the fields in the following variables with your address fields ==========

Set Variable [ $lat ; Value: TO_002____Customers::Site_Address_Lat ]

Set Variable [ $long ; Value: TO_002____Customers::Site_Address_Long ]

Set Variable [ $description ; Value: TO_002____Customers::SiteName ]

Set Variable [ $address ; Value: TO_002____Customers::SiteAddressShort ]

Set Variable [ $city ; Value: TO_002____Customers::Site City ]

Set Variable [ $state ; Value: TO_002____Customers::Site State ]

Set Variable [ $zip ; Value: TO_002____Customers::Site Postal Code ]

Set Variable [ $country ; Value: TO_002____Customers::Site Address ]

# ==========================================================================

#

If [ $lat and $long ]

# first set the coordinates of this record

Set Variable [ $geomarker ; Value: Let ( [   LATLONG = "new google.maps.LatLng(" & $lat & "," & $long & ")" ;   LOCATION = Substitute ( GetAsCSS ( $description & "¶" & $address & "¶" & $city & " " & $zip & "¶" & $state & "¶" & $country  ) ; "\"" ; "'" ) ;   MARKER = "{\"position\":" & LAT… ]

#

# then create the array, putting commas in between each as needed

If [ $n = 1 and Get ( FoundCount ) = 1 ]

Set Variable [ $$LatLngArray ; Value: $geomarker ]

Exit Loop If [ 1 ]

Else

Set Variable [ $$LatLngArray ; Value: $$LatLngArray & Case ( not IsEmpty ( $$LatLngArray) and $geomarker and $n ≠ 1 ; "," & $geomarker ; $geomarker ) ]

End If

#

Else

# there was no lat and/or long data, so log an error

Set Variable [ $errors ; Value: $errors + 1 ]

End If

#

Go to Record/Request/Page [ Next ; Exit after last: On ]

#

End Loop

 

I have attached a stripped done basic version of the actual database. The layout i am working on is the runsheet|Desktop layout.

Please ignore warnings as have tried to make it as small as i can.

Attachments

Outcomes