How to use last record from linked form

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk How to use last record from linked form

Viewing 3 reply threads
  • Author
  • February 12, 2020 at 4:31 PM #39552

    Victor Warner

    Brendon provided some sample JavaScript to enable me to use the first record from a linked form:

    if (passportRecords.length >0) {
    var firstPassportRecord = passportRecords[0];
    var passport_number_id = 'fld-9fe227057cdf44bfa62ad8a97cc6a62a';
    var nationality_id = 'fld-0039b290b2054881ac8f004c01903c6f';
    var country_id = 'fld-6e861fab76b9457bb625953cece54c96';
    var date_of_issue_id = 'fld-0154d8f9ce384e708502fdd775d7bfb1';
    var date_of_expiry_as_text_id = 'fld-b76a031084a94d7e8927ad347e10e24b';
    var number = firstPassportRecord.getFieldValue(passport_number_id);
    var nationality = firstPassportRecord.getFieldValue(nationality_id);
    var country = firstPassportRecord.getFieldValue(country_id);
    var IssueDate = firstPassportRecord.getFieldValue(date_of_issue_id);
    var ExpiryDate = firstPassportRecord.getFieldValue(date_of_expiry_as_text_id);
    result = "date of birth " + record.getFieldValue(date_of_birth_as_text_id) + ", residing at " + record.getFieldValue(address_full_id) + "\r\r" + "Identified by " + record.getFieldValue(gender_id) + " statement and production of current " + country + " passport, passport number " + number + ", expiring on " + ExpiryDate + ", " + nationality + " Citizen"

    I now would like to know how to obtain the last record from the linked Form. I can see how if I wanted the second record or the third record.

    But The issue is that I do not know how many records there are in the linked Form. In some instances there will be only 1 in other 2, 3 or more.

    Is there a command to look for the last record alone or another way to find out the last record and use it?

    Any help would be gratefully received.

    February 13, 2020 at 12:09 AM #39554


    Hi Victor,

    The clue is in the first line of code you posted:


    Since the first record is passportRecords[0], then the last record is passportRecords[passportRecords.length - 1]

    So if there were 10 items in the array, the first one will be at index 0 and the last one will be at index 9.

    February 14, 2020 at 6:40 AM #39563

    Victor Warner


    Thank you.

    Is there a place where this type of syntax is explained or summarised.

    At you mention, but a search ‘length’ produces page after page of entries, none of which seem particularly helpful/digestible for a person who knows nothing about JavaScript.

    February 15, 2020 at 3:39 PM #39570

    Sam Moffatt

    Most of the web based Javascript tutorials will be correct for Apple’s JavaScriptCore that Tap Forms utilises. There are some special objects in browsers like console, window and document that aren’t relevant to JSC and there are some functions not in the ECMA standard that are commonly available in browsers.

    On that note, the w3school’s JS Reference page on arrays should give you a better introduction to arrays though you might find some items don’t quite work. Core elements of the language like arrays should be fine.

    You might want to check out something like Javascript The Good Bits or other books on getting started with Javascript as well to learn this unique and peculiar languages quirks.

Viewing 3 reply threads

You must be logged in to reply to this topic.