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.

Featured Replies

  • Newbies

Greetings,

 

I have manually put together a field calculation that formats proper geojson for my mapbox maps, this formats things fine.

 

Where it doesn't do what I want is in the script loop, it always gives me only one result based on the sorting. 

 

I have also created another calculated field to list all of my other calculated fields and add the header and footer for geojson...same result, it always comes back with only one entry. Even if I try to loop another field, a text, number, whatever, still only one result.

 

Then I tried to export my calculated fields as tab separated text, this gives me all the calculated fields, but then it does not seem easy to inject the closing of the geojson file. The header could be added to the first record, but then how to do with the footer when the last file changes often? Another calculation ?

 

What am I doing wrong, and can it be done any of these ways ? Thank you in advance for any advice.

 

 

My script:

 

Go to Layout [ “table” (field) ]

Show All Records

Enter Find Mode [ Specified Find Requests: Find Records; Criteria: "criteria" ] [ Restore ]

Perform Find [ ]
Go to Record/Request/Page

[ First ]

Freeze Window

Loop

Set Variable [ $filepath; Value:Get ( TemporaryPath ) & "file.geojson" ]

Export Field Contents [ table::field; “$filepath” ]

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

End Loop
Set Field
[ upload::Filename; "file.geojson" ]
Set Field [ upload::CurrentAccount; "account" ]

Set Field [ upload::RemotePath; "path" ]
Commit Records/Requests
Go to Layout
[ “upload” (upload) ]
Commit Records/Requests
Insert File
[ upload::Container; “$filepath” ]
Commit Records/Requests
Perform Script
[ “Transfer” ]
Commit Records/Requests

Go to Layout [ original layout ] 

 

Each iteration in the loop uses the same filename, so you're constantly overwriting the same file, until you end up with only the contents of the last record. (btw, your record-independent file path declaration is within the loop …)

 

Use a variable like $contents inside the loop to build your contents from the individual records; if geojson is a return-delimited format, use List() :

 

Loop

Set Variable ( $contents ; List ( $contents ; table::geojson ) ]

 

then after the loop again use List(), and Set Field to add the header and footer and write the variable into a field:

 

Set Field [ table::exportfield ; List ( table::header ; $contents ; table::footer ) ]

 

then export table::exportfield.

  • Author
  • Newbies

Brilliant, now all works well. Thank you eos.

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.