Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Loop of Found Set inside Script for Web Viewer

Featured Replies

I'm not sure if I have the right approach here. I want to display a google map with multiple pins according to a found set (and in another instance the contents of a portal).

 

I have a script that builds some text/html using 3 Set Field statements. Each Set Field statement is just plain text.  The Set Field is then displayed by a Set Web Viewer step into an Object.

 

The 1st and 3rd steps are common javascript, the 2nd step is a javascript array of addresses which is hardcoded for now, but should eventually be constructed from the data in the found set.  With the hardcoded array the script would product the following text which will display a multi-pin map. 

data:text/html,<!DOCTYPE html>  
 <html><head><meta charset='utf-8'><title></title>
 <meta name='viewport' content='initial-scale=1.0, user-scalable=no'>
 <style type='text/css'>
 html { height: 100% }body { height: 100%; margin: 0; padding: 0 }#map-canvas { height: 100% }</style>
 <script src='https://maps.googleapis.com/maps/api/js?key=&sensor=false'></script><script>
 var geocoder;
 var map;
 function initialize() {
 geocoder = new google.maps.Geocoder();
 var latlng = new google.maps.LatLng( 43.670234 , -79.386737 );
 var mapOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }
 map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
 var locations = [            


'229 Ashworth Avenue, Toronto ON',  
'1112 Queen Street East, Toronto ON',  
'889 Yonge Street, Toronto ON',  
'1711 Melrose Avenue, Toronto ON',  
'2500 Yonge Street, Toronto ON',  
'45 First Avenue, Toronto ON'



             	];  
 var i; 
 for (i = 0; i < locations.length; i++) {  
 geocoder.geocode( { 'address': locations }, function(results, status) {  
 map.setCenter(results[0].geometry.location);
 var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location });});}}  
 google.maps.event.addDomListener(window, 'load', initialize);  
 </script> 
 </head><body><div id='map-canvas'></div></body></html>

What I am trying to figure out is how to replace the hard coded array of addresses in the middle with the data from looping through the found set

 

I have tried something like this as the 2nd script step to build the array, but it is empty.


Loop
    Go To Record/Request/Page [Next; Exit after last]
    Set Field [Map::HTML; GetFieldName(Map::address) & ", " &  GetFieldName(Map::city) & ", " & GetFieldName(Map::province)]
End Loop

How should I go about this?

 

Thanks.

Solved by eos

Go to solution
  • Author

In case my explanation is hard to understand here is the sample database with the 2 scripts.

You should see the first script will display the map with pins.

The second script will display the map, but the address array will be empty - so no pins.

Maps.fmp12.zip

You could hardcode part A and C (in fields or variables), dynamically build up part B with the addresses from the loop within a variable, combining markup and data, and finally join A,B and C.

  • Author

Yes that's precisely what I proposed.

 

What I'm looking for is the "how to" dynamically build the array from the found set.

As you stated, "dynamically build up part B with the addresses from the loop within a variable".  What is the proper syntax to do that?

 

Thanks.

  • Solution

Have a look at the modified script.

Maps_eos.fmp12.zip

  • Author

I see what you've done to build the array, (although it seems a little convoluted in FM speak) how the looping works.

 

It does work - Thank You!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.