Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 2,806 through 2,820 (of 3,049 total)
  • Author
    Search Results
  • #30936

    In reply to: Location Field Editing

    Brendan
    Keymaster

    Hi Kenneth,

    Which version do you have? You can do this on the Mac version by clicking the location button on the field in the record and then changing the coordinates in the field there. Plus you can edit the name itself on the record details view.

    I suspect you could do it with a script as well.

    The structure of the Location field value is a dictionary that looks like this:

    {
            altitude = "2674953.657398775";
            heading = "-0";
            lat = "50.337885";
            lon = "-115.853054";
            pitch = 0;
            title = "4992 Falcon Dr, East Kootenay F BC V0B 1L1, Canada";
    }

    Not all values are required. The heading, altitude, and pitch values are just for supporting the 3D map view on the Mac version.

    So ya, if you can generate a dictionary of values like the above, you could probably use it with the record.setFieldValue(fld_id, value); function.

    Thanks!

    Brendan

    #30934
    Brendan
    Keymaster

    Hi Martin,

    I haven’t written any code to enable access to the clipboard. I’m not sure that JavaScript directly allows that so I would have to write some Objective-C code that allows access to it.

    Thanks,

    Brendan

    #30931
    Kenneth James
    Participant

    Location Field Editing

    I use Tap Forms as a logging device to capture events that have date/time and location components. There is a problem with Apple Maps (and presumably with Google Maps as well) that it does not identify the correct address with the GPS coordinates. As an example, an event logged at my home places the address of my home over on the next block with a totally erroneous street address. Unless you have some secret mechanisms with Apple APIs to tweak this, I have found no other way. Locations are always wrong in any app that I use that captures location data.

    So my question is about how to edit these erroneous addresses. Can you share what the internal structure of the Location field is. At a minimum there seems to be the text component that holds the found address. Then there are one or two fields to old the longitude and latitude as single data points, or as one data point.

    Can these internal Location field structures be edited by either a calculation field or a script field? And if so, how.

    Ideally, I would like to establish the coordinates of a GPS rectangle that surrounds my house at a reasonable distance. Then test the GPS coordinates populated in the Location Field. If these coordinates are within this pre-established rectangle, then reset the captured GPS coordinates to the one, and only, GPS coordinate for the center of my house. Then change the address portion of the field to the correct address of my house.

    Is this possible within Tap Forms? Or does it involve exporting the database to Excel or some other tool and doing the edits there?

    Thank you for your counsel.

    Kenneth James

    #30930
    Martin Kendall
    Participant

    Is it possible for a JavaScript script to read the iOS clipboard?

    I like to quickly note new entries in plain text in other apps (e.g. Drafts). I know there isn’t a full Tap Forms URL scheme at the moment, but the ability to run a form script that creates a record from the clipboard contents would be fantastic.

    I hope it is possible,

    Martin
    Ps Setting the clipboard too would be great to send data to other apps, but that is of lesser importance

    #30920
    Brendan
    Keymaster

    A Document in Cloudant nomenclature is equivalent to an “object” in Tap Forms. And by “object” I mean a form, a record, a field, a pick list, a category, a script, a layout, a layout item, etc. I call the entire database a document because that’s what it is for Tap Forms. A document file (with a .tapforms file extension) contains within it an SQLite database file and a properties file and all of the attachments you add to your database.

    So each of those things needs to be less than 1 MB big in order to sync. So if a record is more than 1 MB, it won’t sync and you’ll get an error. But unless you are putting a ton of information into Note fields (or pasting images into them), you’ll probably be fine. Tap Forms shows how big the record is at the bottom of the record details view for precisely this reason. The size you see there is not including the attachment sizes.

    Hope that clears it up a bit.

    Thanks!

    Brendan

    #30910

    In reply to: Shortcuts integration

    Brendan
    Keymaster

    Here’s an example video showing using Siri to execute a form script:

    https://www.dropbox.com/s/dldur76m8nvcb2x/Siri-ShortCuts-Demo.MP4?dl=0

    #30909

    In reply to: Shortcuts integration

    Brendan
    Keymaster

    Hi,

    The Shortcuts support is specifically designed right now for using Siri to execute a Form script that you create in JavaScript.

    For example, if you had an expenses form with a Saved Search that lists the expenses this month, you could ask Siri “This month’s expenses” which would execute a form script that returns those results to you within Siri.

    You could certainly have Tap Forms create and edit records within a script, but Siri shortcuts executed like this can’t accept parameters. But if you needed to insert or update the same data for every execution of the script, then that would work. For example, if you go to Starbucks and you buy the same priced coffee every day, you could write a script to add an expense record for this and record a Siri command such as “Coffee Time” and have it execute a script called “Add Coffee to Expense” or something like that. Or even call the script “Coffee Time”.

    You can have a script return any data you like. But I haven’t specifically tested it when using the Shortcuts app. It’s just calling a script via Siri at the moment.

    If you go through the on boarding process again by tapping the bookmark icon on the Documents screen in Tap Forms for iOS and choose the Todo and Expenses forms, they will include a couple of form scripts you can try out.

    Thanks!

    Brendan

    #30891
    Brendan
    Keymaster

    Hi Andrew,

    I would recommend using a Saved Search to filter the records which have been checked. That way you can either decide to delete them all in one go or have access to them later on.

    Alternatively you could use a Script field which will delete the record when the checkmark value changes.

    The only problem with that is it wouldn’t update the list right away to remove the record. You’d have to manually refresh the list of records.

    Brendan
    Keymaster

    Hi Carol,

    I’ve already added the JavaScript support to Tap Forms. I suppose you could do something to pull data into the parent record which you could then search on from the parent. You would just need to create a Script field in your form, write some code to extract out the data from the Link to Form field’s sub-fields, then return that value. It would display in the parent form. Then you could create a Saved Search that scanned that data. It would probably be for a very specific search that you’d want to do rather than being able to search any sub-field on the child form.

    I haven’t written any code to create Saved Searches that can query the child relationships on a parent form directly.

    Carol Jones
    Participant

    You helped me with an earlier question about my TapForms database and now I have another question. I have this main/major/parent form that is a list of members, artists and interested people of our nonprofit arts organization which contains contact information and other stuff imported from an old filemakerpro database when we first started using TapForms in May of 2018.

    I created a new form that is a record of memberships and donations some people in this list have paid. There is a linked field in the parent form showing the data/amounts they have paid, dates they paid, type of payment, check number, etc. There is also an “inverse relationship” field in the memberships and donations table/form that brings in the phone number and email and company name, etc. from the parent form so we can see more information about who paid. This is nice. Works fine.

    I had asked you in an earlier question about changing the type of relationship link in the parent form and I understand your answer but have not changed the type of link yet. I am putting it off to ask this NEW question.

    Sometimes I want to search in the parent form for a person who has paid between certain dates, or paid a certain amount and it is impossible because the data in the linked field, which is a table when viewing the form, is not visible in the list of fields that I can search on.

    Also, I recently created a yet another child form/table of items in a specific event (a gallery show of artists’ work) that were submitted by some of the people/artists in the parent list, about 55 items (sometimes one person has submitted more than one item). There is a linked field in the parent form where we can enter the item numbers and specifics about the items submitted by the artists, and there is an “inverse relationship” field in the item list showing the artist name and company and address from the parent form (or whatever I choose to show). All works fine, I was able to create a price list of the items and we have been able to adjust things just fine. Beautiful.

    However, just like the above mentioned impossibility, if I want to search in the item list for information about the artists who have submitted items, that is impossible because none of the artist information is visible in the search. I realize I can search and find items in the form showing the artist information and can go to that individual record with the little arrow, one by one, but that is rather tedious.

    I read about how you were going to add some javascript capability (I do not write javascript myself at all) and I was wondering if this new functionality would make it possible to do what I want to do, and if so how and who could do it?

    Is it going to be impossible forever or is there something simpler that I can do?

    Thank you for the new update/upgrade(s), I love TapForms and love that you are keeping up with the Mac OS updates. I would love it more if I could do what I want to do.

    Your fan,

    Carol Jones

    #30728
    Brendan
    Keymaster

    Good idea. I just added my example to the online user manual, along with the other 2 scripts that are there as examples.

    Thanks!

    Brendan

    #30727
    David Butenhof
    Participant

    Huh. Yeah, it seems to work with or without the trailing semicolon, so I have no idea why it didn’t work for me the first time I tried. In any case, it does now.

    And thanks for pointing out that an explicit refresh would update all the records; that hadn’t occurred to me.

    And, by the way, all of this would be great detail to put in the manual, along with a full example of a field script returning a real value.

    var movies_views = record.getFieldValue('fld-100d486783794f95a5ba1091e901c85e');
    var count = movies_views.length;
    var old_count = record.getFieldValue('fld-78570a9d833949f6877468ad32aab974');
    if (!old_count) {old_count = 0;}
    var total = count + old_count
    total;
    #30726
    Brendan
    Keymaster

    Yes you can run the Script and Calculation fields by clicking the Refresh button at the bottom of the records list. Tap Forms will loop through each record and find any Calculation and Script fields in your form and it will execute them for every record.

    You do need to have a semi-colon at the end of each statement. But the last statement should just be the variable or string that you want to return.

    For example:

    var amount_id = 'fld.....';
    var quantity_id = 'fld....';
    var amount = record.getFieldValue(amount_id);
    var quantity = record.getFieldValue(quantity_id);
    var total = amount * quantity;
    'The total is: ' + total;
    

    So the last thing in the script is just 'The total is: ' + total; which is the return value from the script. You would need to set the Result Type to Text. If you just want to return total; then you would leave the Result Type set to the default Number.

    Hope that helps!

    Brendan

    #30725
    David Butenhof
    Participant

    Thanks.

    I tried again and it worked. In retrospect, I suspect my problem the first time was the reflex to close each line with a semicolon, which of course would have meant the field script wasn’t returning a value at all.

    Ooops!

    But whereas using a separate “total” number field I’d been able to set the field in every record with a form script, that doesn’t work now that I’m using the field script properly. Is there a way to make the script run for each record without actually changing a field, or do I have to do something dumb like adding a space to a text field just to force an update?

    #30721
    Brendan
    Keymaster

    Hi David,

    I haven’t written any code to allow a script to call another script. But we did talk about that in the beta forum a while ago.

    A Field script does operate the same way a Calculation field works. Whenever the fields that are referenced in the script change, that’s when the script gets executed. Whenever you save a Field script, Tap Forms looks for any getFieldValue() calls. It then builds a list of fields that are referenced in that script and it saves it to the field. Whenever you change a value in the record for any of those fields, Tap Forms will execute the script. Whatever the last value is that’s returned from the script will be stored in the database and displayed in the field.

    Make sure you set the Result Type appropriately to match the value type you’re returning from the Field script, otherwise you won’t see anything. So if you return a string, then set the Result Type to Text, etc.

    Hope that helps!

    Brendan

Viewing 15 results - 2,806 through 2,820 (of 3,049 total)