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 - 1 through 15 (of 3,151 total)
  • Author
    Search Results
  • #54829
    Michael Stoehrel
    Participant

    Hi all

    Based on a status field a script should run some calculations and/or cleanup tasks.
    One part of the cleanup is to remove a record in a “Link from Form” field.
    Or in other words the script should execute simply the “-” button in the field…

    Any ideas are welcome.

    #54828
    Brendan
    Keymaster

    Changing all the icons was one of the things I did when I overhauled Tap Forms 5 to become Tap Forms Pro (plus many many more features an enhancements and swapping out the entire back-end database engine).

    Tap Forms 5 was basically written before the days of dark mode and updating the custom layouts to fully support dark/light mode switching was a big undertaking at the time. You no longer need to fake it with a black background to pretend to be dark mode. Tap Forms Pro does it all for you.

    You could add a Form Script button which presents an alert with a pick list of values you can select from a popup button and have it put the selection into a field.

    var output = function printOut(continued) {
           if (continued == true) {
    	   console.log(username + ", " + password + ", " + email_address + ", " + other_field + ", " + genre);
           } else {
              console.log("Cancel button pressed.");
           }
    }
    
    var username = 'test username';
    var password;
    var email_address;
    var other_field;
    var genre;
    var genres = ['Action & Adventure', 'Comedy', 'Drama', 'Horror', 'Science Fiction'];
    
    let prompter = Prompter.new();
    prompter.cancelButtonTitle = 'No Thanks';
    prompter.continueButtonTitle = 'Go For It!';
    prompter.addParameter('Username: ', 'username', '', '', username)
    .addParameter('Password: ', 'password', 'secure')
    .addParameter('Email Address: ', 'email_address')
    .addParameter('Other: ', 'other_field')
    .addParameter('Genre: ', 'genre', 'popup', genres)
    .addParameter('Media Type: ', 'media_type', 'picklist', 'Media Types List')
    .show('Enter a Username and Password and Stuff', output);

    You can then place your buttons anywhere on your layout.

    Unfortunately there isn’t a way to replace the accessory button icons inside the app.

    Although another kinda awkward solution would be to place a white filled rectangle behind each accessory button so they stand out from the black background though. Use the Layers tab to place the rectangles behind the buttons.

    Thanks,

    Brendan

    #54827
    Chris Knight
    Participant

    Hi Brendan,

    Thank you for your reply. So, what you are saying is that I cannot change the color of the icons in TapForms5. Correct?

    Is there a way then I can script my own inserted image to open the correct picklist or the calendar date chooser thing?

    Or, some other way, in TapForms5, it be able to wither see the built-in accessory control icons on a dark background, or get the same functionality that they are there to provide?

    Thanks in advance,
    Chris

    #54821
    Chris Knight
    Participant

    Hello,

    I made a mistake and ‘upgraded’ my TapForms 5 and when I did the Accessory Controls all became impossible to see. Unfortunately I don’t know what version of TapForms 5 I had been on as I have not been using very much at all for the last several years.

    Anyway, what I have (and have had working for a long time) has a custom layout that has a black background because I can’t use apps that don’t have support for a Dark Mode. Now the Accessory Controls are practically invisible as they lack enough color contrast and I would almost swear that the line thickness has changed but it has been so long since I last used TapForms I am not really certain of that. What I nee to know how to do is change the color of the Accessory Controls to have more contrast. Maybe even make them a little larger.

    Screenshot is attached.

    P.S. I don’t do subscription software. At all, ever, period. So, if migrating to Tapforms Pro is the only answer that is a shame. I will have to find a solution that does not cost $400 to use on the rare occasion.

    Attachments:
    You must be logged in to view attached files.
    #54812
    PierreBn
    Participant

    Thanks Brendan, that was quick!

    Thanks for the great fixes. And agreed: null for a cleared date and no links in list_records both make sense.

    The setup is really great and easy by the way. I like that access is set per document.

    Numbers and region: as I understand it, the MCP itself can tell the AI the expected format (dot for decimals, no currency sign), so users don’t have to. Not sure TBH, but maybe a short note in the tool descriptions is all that’s needed? Same for “yes” on check marks.

    Rating: I didn’t know it goes up to 10, sorry! So the PDF is right, my mistake. I’ll check the field again in the UI, maybe just a display/refresh issue.

    Permissions: I’m not a developer, so no strong opinion. Full CRUD might confuse users I think (“update” vs “write”). Maybe three levels: 1. Read 2. Create & Write, 3. Delete. And yes, I meant per document.

    Still open, if useful:
    – Dates: 2026-02-30 is stored as 2 March. An error would be safer IMHO.
    – A time without a time zone is read as UTC, so it ends up one hour off here. ISO 8601 treats it as local time. Reading it as local time, or a note for the AI in the MCP, would solve it.
    – Linking (join link, unlinking from the Link from Form side): I’ll double-check on my side, maybe a refresh issue.
    – Audio recordings and signature come back empty in get_record. I don’t use them, but it might help other users.

    I’ll test again with your next update ;)

    Pierre

    • This reply was modified 1 week, 3 days ago by PierreBn.
    • This reply was modified 1 week, 3 days ago by PierreBn.
    #54799
    Brendan
    Keymaster

    Hi Mark,

    I generally add APIs to the scripting system when people ask for them.

    You’re the first to ask for an API for tags. I can work on adding the obvious ones such as createTag(), updateTag(), deleteTag(), tagRecord(), etc.

    Thanks,

    Brendan

    #54794
    Mark Moran
    Participant

    Am I missing it or are there no script calls for tags?

    Mark

    #54776
    John Hamill
    Participant

    I provide below some follow-up information on Tapforms ‘Date type’ fields while using JavaScript. I include this information as it may save users some time in the future as they navigate the many “minefields” I encountered when using date objects.

    COMPARING DATES IN TAPFORMS:

    ‘Date type’ fields in Tapforms are held containing both the date and the time. The following Javascript program operates upon a ‘date object’ which contains a date with no associated time (courtesy, https://www.geeksforgeeks.org/javascript/compare-two-dates-using-javascript/).

    ——– Script excerpt ——–
    const date1 = new Date(‘2024-08-29’);
    const date2 = new Date(‘2024-09-01’);

    if (date1 < date2) {
    console.log(‘date1 is earlier than date2’);
    } else if (date1 > date2) {
    console.log(‘date1 is later than date2’);
    } else {
    console.log(‘date1 and date2 are the same’);
    }
    ——– End excerpt ——–

    Comparison operators (as demonstrated in the above script) report accurately with a ‘date only’ object. This behaviour may NOT operate as expected when the time element is included within a date object. Some of these “problems” are described in the enclosed email conversation with Brendan Duddridge.

    As a result, one might consider the option of comparing dates using “stringification instead of comparing two date objects. I have tested this myself and it works perfectly well with Tapforms ‘date type’ fields.

    STRINGIFY A DATE

    The following text is from https://stackoverflow.com/questions/14781153/how-to-compare-two-string-dates-in-javascript:

    Despite some confusion in the comments here, this [comparing dates after stringify^] does work for all YYYY-MM-DD dates. The original question was asking about “m/d/yyyy” dates, but most of us are using YYYY-MM-DD internally, so this is the best solution for most cases.

    ^ To stringify a date to ‘YYYY-MM-DD’ (Courtesy, https://www.geeksforgeeks.org/javascript/how-to-format-javascript-date-as-yyyy-mm-dd/):

    ——– Script excerpt ——–
    const formatDate = (date) => {
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, ‘0’); // Months are 0-indexed
    const day = String(date.getDate()).padStart(2, ‘0’);

    return ${year}-${month}-${day};
    };

    // Example usage
    const currentDate = new Date();
    console.log(formatDate(currentDate));
    ——– End excerpt ——–

    **** Example usage for a Tapforms date type field: ****

    ——– Script excerpt ——–
    const formatDate = (date) => {
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, ‘0’); // Months are 0-indexed
    const day = String(date.getDate()).padStart(2, ‘0’);

    return ${year}-${month}-${day};
    };

    function f_script_correct() {

    const prescription_date_obj_val = record.getFieldValue(‘fld-32bdd5c589f347e7add9b39c9a2099a4’);
    const prescription_date_obj_val_previous = record.getFieldValue(‘fld-f04dfccc25e14986894a5d77a8370ad6’);
    var prescription_date_string_val = formatDate(prescription_date_obj_val);
    var prescription_date_string_val_previous = formatDate(prescription_date_obj_val_previous);

    if(prescription_date_string_val == prescription_date_string_val_previous)
    Utils.alertWithMessage(‘Date’, ‘The same date’);
    else
    Utils.alertWithMessage(‘Date’, ‘Different dates’);

    }
    ——– End excerpt ——–

    ********* Javascript date issues **********
    In summary, the use of dates within Javascript (comparing dates, calculating days between dates etc) is a minefield as evidenced by the email exchange with Brendan Duddridge. I have found through research that the functions above solve some of these problems when using ‘Date type’ fields within Tapforms.

    This solution is for comparing dates absent the time element. If your program environment is dependent upon daylight saving time or time zones (for example), this solution may not be suitable. Note also that this information has not addressed the addition and subtraction of dates (date arithmetic). As explained in the email exchange, there are inaccuracies (of typically one day) when utilising the function ‘getDaysBetween(date1, date2)’.

    Keywords (to aid forum search): comparing dates; date comparison; javascript date problems; days between dates; subtracting dates; error NaN; undefined; date object; calculating dates; date calculation

    Attachments:
    You must be logged in to view attached files.
    #54739
    John Hamill
    Participant

    Hello,

    I am using JavaScript and I have a situation where I need to reset a particular field to null if another field in a record has “changed value” (been amended by the user).

    My understanding is that in a field level script, the script will only be executed if a getFieldValue command is included in the script – this is the trigger to execute the script. Once the script is executed, the script will then reference the *new* values that the user has entered.

    Considering this, how can I determine if a user has amended a particular field in a record. I have the information that the user has definitely changed some of the data in the record, but how can I determine if he has changed a value in a particular field?

    Thanks for any assistance.

    • This topic was modified 3 weeks, 1 day ago by John Hamill.
    • This topic was modified 3 weeks, 1 day ago by John Hamill.
    #54734

    In reply to: Any ideas?…..

    Brendan
    Keymaster

    Hi Michael,

    If you’re referencing a Link to Form or Table field in a Calculation, you will get COUNT() as the aggregate calculation for a non-numeric field. That’s because there could be multiple records in the Table or Link to Form field, so Tap Forms doesn’t know which record you want to get the value of. So it defaults to an aggregate function.

    If you want to get the value of a specific field and a specific record in a Table or Link to Form field then you have to use a Field Script for that. I’m not sure what you mean though that Scripts can’t seem to show a result of a cascading Pick-List. I don’t know what your script looks like, so I don’t know if what you’ve programmed is correct or not. And I’m also not sure why the Child record loop isn’t working. Did you select a field from your child form before you double-clicked on the Child record loop script?

    Thanks,

    Brendan

    #54733
    Michael Dandeo
    Participant

    I need to copy the result of a pick-list and display into a different text field.
    The pick-list is a Cascading Pick-List inside a table and I only need the primary category.
    Category 1
    Category 2
    Category 3

    Why am I trying to do this…..Having a pick-list inside a table means its not searchable and Tags doesn’t seem to work either. Also can’t display it in a column in records view.

    What doesn’t work….
    When I create a new separate calculation field to pull the column from the table it copies over as a COUNT(), which obviously doesn’t work even if its set to display as text.
    Scripts can’t seem to show a result of a cascading Pick-List but does show in Log with no errors, just blank. Child record loop doesn’t work either.

    I know what im doing can be fixed by having 3 separate text (Pick-List) fields. But since every record needs all 3 Categories, why not save space and make the form flow a little better.

    Any suggestions would be helpful. Hoped I described in a way that makes sense to someone else.

    #54715
    Brendan
    Keymaster

    Hi Pierre,

    Tap Forms Pro 1.5 will now have a built-in MCP Server. I apologize if I’ve stepped on your JavaScript implementations. I’ve had a few requests for it recently, so it seemed like a good time to work on it.

    It’s of course a work in progress and it will be great to have your feedback once it’s published.

    Thanks!

    Brendan

    #54712
    Daniel Leu
    Participant

    Yep, the API is very powerful and thankfully, Brendan has always an open ear to add some new features, as he did for my MCP implmentation!

    I didn’t look at your code, but based on your description, I did about the same thing. One thing I noted is having special prompts greatly improves results. Initially, I just had fetchRecords, but then Claude fetched all records to perform a search. So adding searchRecords with an additional field filter reduced the data Claude had to process. It’s a fun project!

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #54706
    PierreBn
    Participant

    Hi Brendan, Daniel,

    Thank you to you both.
    I didn’t realise how rich the Tap Forms scripting API was. So I built my own MCP connector on top of it.

    It runs a local http server on the Mac, plus one form script (“MCP Bridge”) in the TapForms document. Claude and the ChatGPT Mac app (or any MCP compatible AI) can then search, read and edit records. The AI only fetches the records it needs. So no huge exports, Brendan, which was your main worry about tokens.

    It can read and write most field types, links, tables, photos and files. Every change needs my approval in the AI app. Deletes need a click in a Mac dialog, and a backup is made first.

    Daniel, your unofficial API reference was a huge help. Table columns and link types come from properties documented there. Thank you! I am sure your version is cleaner than mine

    Brendan, I also noted a few things I ran into in the API while testing. They might be overall API limitations (outside of the MCP use case). For example, clearing a date field from a script doesn’t seem to stick, and local files can’t seem to be attached with addFileFromUrlToField. The full list, with steps to reproduce, is in the docs folder (tapforms-issues.md).

    WARNING: I want to be very clear this was vibe coded (with Claude Opus 5.5) and only partially human reviewed by me (just a hobby-developper). It has been tested on a copy of my database, and I will keep testing it in daily use. But it is NOT production ready in any way. Only try it on a copy, with a backup.

    Download: file attached.
    Start with the README, then docs/setup.md.

    This works for me for now. But it would be great to have an MCP server built into Tap Forms one day (Joplin still a good example: the MCP server runs inside the app itself).
    It would make this user friendly and more accessible to (nothing extra to install or start, no need to paste the script into every document…).

    Pierre

    #54705
    Daniel Leu
    Participant

    Right now, I haven’t posted the MCP script yet. Busy with other work.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

Viewing 15 results - 1 through 15 (of 3,151 total)