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,626 through 2,640 (of 2,866 total)
  • Author
    Search Results
  • #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

    #30713
    David Butenhof
    Participant

    It’d be great to make this more of an IDE. You have some syntax color tagging, which is nice; but for example it’d be great to be able to re-indent a script to prettify it, and to be able to select a range and use TAB and SHIFT-TAB to indent and de-indent a block.

    The mechanism for referencing fields by “ID” is also awkward, especially since the only way to get the ID is to use a button that inserts a complete assignment statement. At the very least, a lookup function that takes a field name and returns the ID would make this a bit easier to work with; and also make the script a lot easier to read.

    (And, by the way, in case it’s not obvious, I think this addition is an amazing idea.)

    #30712
    David Butenhof
    Participant

    What I initially expected doesn’t seem to be the way it works, or maybe I just can’t figure it out.

    You’ve got both “field” and “form” scripts. The documentation even hints at “field” scripts as an extension of the spreadsheet-like calculation fields; but I wasn’t able to figure out how to set a value for the script field. In a spreadsheet, each cell has both a “formula” and a “value”, and that’s how your calculation fields work as well, but the Javascript fields don’t appear to work that way. The sidebar won’t even let me find a field ID for the script field, so if it’s possible there has to be some trick to it; and simply returning the desired value doesn’t appear to do anything. Is this possible, or do I really need to define both a script field and a value field where the script stores the result?

    I also found out that the field script runs only when the record is saved, so adding a “compute total” calculation script field didn’t update the “total” column until I manually modified each record. A simple adaptation in the form of a form script that iterated through the records took care of that … but is it possible to make a form script that iterates over the records and directly calls a script in each record instead of duplicating the code?

    #30702

    Topic: V5.3 Manual

    Ron
    Participant

    How do I access the new manual.

    “New Tap Forms 5.3 manual, including a section on the JavaScript API you can use to write scripts to read and manipulate your records.”

    Ron

Viewing 15 results - 2,626 through 2,640 (of 2,866 total)