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,716 through 2,730 (of 2,950 total)
  • Author
    Search Results
  • 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

    Brendan
    Keymaster

    Oh, also that console.log() statement isn’t needed. I was just printing out the end_mileage value to see what was in it.

    I’m glad you found it useful.

    I think Scripts will open Tap Forms up to a universe of possibilities.

    Brendan
    Keymaster

    Here’s what the script looks like:

    var vehicle_id = 'fld-64b0b17a635f49b8b40867e45f8d24db';
    var start_mileage_id = 'fld-9674e316bfed408ca6710ce81b72bf05';
    var end_mileage_id = 'fld-eed890f4533f4672817c5ae5d4dc8257';
    
    var vehicle = record.getFieldValue(vehicle_id);
    var end_mileage = record.getFieldValue(end_mileage_id);
    
    var newRecord = form.addNewRecord();
    newRecord.setFieldValue(vehicle_id, vehicle);
    newRecord.setFieldValue(start_mileage_id, end_mileage);
    
    console.log(end_mileage);
    
    form.saveAllChanges();

    So whatever record is currently selected at the time you run the script will be what record is. The code gets the values from that selected records, then tells the selected form to add a new record, then it copies the vehicle name to the same field in the new record and copies the end_mileage value to the new record’s start_mileage_id field.

    Easy peasy :)

    Ok, for someone who knows how it works. But it’s really not that complicated once you see it written out.

    Brendan
    Keymaster

    Ok, here’s a Mileage Tracker form with a Form script that will do what you asked for.

    Attachments:
    You must be logged in to view attached files.
    Brendan
    Keymaster

    Hi Daan,

    That’s a really good idea and certainly doable. You would probably want to use a Form script for that. The nice thing about form scripts is you can just reference whatever current record is selected, then tell the form to make a new record within the script, copy the values from the current record and stuff them into the new record.

    So what you would do is select the latest record, select the script (which you can also assign to a shortcut key) and run the script.

    I’ll make an example form and post it here.

    Daan
    Participant

    Hi Brendan, it would be great to get some working examples to quickly learn and understand how to use the new JavaScript feature. If you need an useful application for a script, I might have one… ?

    I use TapForms for a logbook documenting my boat trips. In this logbook, I keep the records sorted by ‘trip start date’ (one of the fields). When adding a new record, I would like to copy several fields from the previous (=most recent) record to the newly created record. This would allow me to automatically copy the ‘mileage upon arrival’ field from the most recent record to the ‘mileage on start’ field for the new record. The same applies for the ‘Arrived at’ field from the most recent record, I would like to copy (or pre-fill) the contents of that field to the ‘Start from’ field in the newly created record.

    I can imagine this might be useful for others as well. Would you be able to give an example implementation of a script doing something like that?

    Thanks in advance!

    Daan

    #30662

    In reply to: Character input

    Yoo Byeng Han
    Participant

    The phenomenon of the first character being released and the last character being deleted when entering Han-gul.
    https://www.dropbox.com/s/c3c2yokfg7ywc8p/Tap%20Forms_Hangul%28korea%29.mp4?dl=0

    #.First characterization issue: essentially update from Tap Fprms.
    UTF character transformation (unabsorbed, neutral, and longitudinal) is required, and then reassembled and applied as fields.

    #.Troubleshoot problems with deleting end characters in File Maker Pro
    1.Enter text in field
    2. Creating Scripts
    if [Code (Get key input trigger ) = 10 Code (Get (key input trigger ) = 13 ]
    Perform the script [ “A” ; ]
    OnTimer Script Installation [ ; ]
    script [text result: 0 ]
    End if

    3 “A” Script Creation
    OnTimer Script Installation []

Viewing 15 results - 2,716 through 2,730 (of 2,950 total)