December 19, 201312 yr 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 ]
December 19, 201312 yr 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.
Create an account or sign in to comment