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,135 total)
  • Author
    Search Results
  • #54635

    In reply to: Conditional formatting

    Melanie Schaaf
    Participant

    Hey everyone,

    I also have a few questions about conditional formatting and observed some strange / annoying refreshing behaviors.

    Let’s talk about formatting rules first.

    I have tested this first with a condition based on a text field (with a pick list to be precise); Make text red if text field equals “Red”.
    This works perfectly in all three layout types (Default, Custom and Universal), the text color in the conditional field refreshes immediately when I change the value in the text field.

    When I make a condition based on a checkmark, however, (e. g. Make text red if checkmark is false), I noticed that while in Default and Universal layout, the text color refreshes immediately like with the other condition described above, when I turn the checkmark off and on, but in my *Custom* layout it doesn’t refresh. I have to either leave the record and go back to it, to see the switch in the checkmark affect the text color, or I have to press the “Recalculate formulas and scripts for all records”-button for it to change the color. Simply pressing “Recalculate formulas” will *not* trigger the format switch either, which I suppose it should, if recalculate all works, why shouldn’t recalculate this one record work?

    But apart from that I guess the formatting should update in my Custom layout right away, like it does in the other two layout types and with the other conditions… 




    Let’s move on to visibility rules.

    I have tried a condition that states: Show field when List field is equal to “Show”.
    The field will always show, no matter what the value in my List Field is, in every layout type, whether it is Default, Custom or Universal.
    I also tried a condition with a number field (Show when number field is greater than “5”), this also did not work. Neither did a checkmark with a similar condition with show.

    So I have been wondering what kind of conditions would work with the “Show” option? I have not been able to find any in any layout.
    I even tried the Hide Field in the field options (which by the way only hides the field in the Default Layout, it remains visible in Custom and Universal), thinking that maybe if the field was hidden by default, “Show” in Conditional Formatting might make it visible. This doesn’t work either.

    So next I tried the opposite: Hide field when List field is equal to “Hide”.
    This works in the Default layout, but only after I leave a record and re-enter it (both “Recalculate”-buttons won’t refresh it this time).
    It doesn’t work in the Custom layout at all, neither with “Recalculate” nor by leaving and re-entering the record.
    It works in the Universal layout immediately after I change the value.

    I tried this with a Checkbox field and the Hide action and the behavior is exactly the same.

    I also tried hiding an image field, which also showed the same results; worked immediately in the Universal Layout, kinda worked in the Default Layout, after leaving and re-entering record, recalculation does nothing, and it doesn’t work at all in Custom Layouts.

    Apart from the refresh and recalculate issues, this brings me to the question: Is the Visibility Conditional Formatting simply not available in Custom Layouts? Is it planned for future releases?

    And why is the refreshing behavior so inconsistent throughout different conditions and layouts?

    Brendan, when you are reading this, I’d be happy to send you my test database via email, though I am pretty sure the behaviors I described above are universal. At least I was able to reproduce them in my other databases…

    All this has been tested on MacOS.

    Looking forward to your feedback!

    Thanks!

    Melanie

    #54620

    In reply to: Scripting on iPad

    Brendan
    Keymaster

    Hi Karen,

    Thanks for re-subscribing to Tap Forms Pro!

    You can do all the same stuff (mostly) on the iPad scripting as you can on the Mac.

    The UI is slightly different on iOS though for writing the scripts. But the editor itself is the same.

    The API and examples are here:

    https://www.tapforms.com/help-mac/pro/en/topic/scripts

    The Mac manual’s scripting API is the same as for iOS.

    Thanks,

    Brendan

    #54618
    Brendan
    Keymaster

    Yes, Table fields will also migrate. Just use the Send to Tap Forms Pro function as in my demo video and that’ll do everything for you (aside from the attachment aliases issue above).

    Yes, all data is stored locally on your devices. Not in the cloud unless you enable iCloud, Cloud+, or Dropbox sync.

    Well, you still have to tell Tap Forms what fields you want. Or you can import from a library of pre-defined form templates you can install from the Template Library. Or you can use the new “Create Form with Fields” function which will use AI to generate a form for you based on the form title and optionally a description.

    #54617
    karen james
    Participant

    I’d like to start by saying:
    I had started using Tap Forms when Bento became obsolete. I loved it! When Tap Forms Pro came out I subscribed, iPad only, even though I’m no fan of subscription based apps. I let the subscription lapse because I didn’t see the value. However, the new updates called me back, and I renewed my subscription. I’m still not a fan of subscriptions, but I feel this one is worth it. I still don’t use it on my iMac. I need the iPad version only, so I’m hoping more of the Mac functionality comes to the iPad. Leading to my question!
    Does scripting work okay on the iPad? I don’t mean, do scripts work, I mean writing them. There’s so little iPad documentation, I’m not sure what I can do.

    #54598
    Marcel Halbeisen
    Participant

    So, I also try to use the data base now on my MacBook, but it totally failed. It’s absolutely not possible to sync the complete datas from the Cloud+ Sync to the MacBook. Only around 40% of the entries come to the MacBook.
    I also tried to open the backup from the iPhone on the MacBook, which works, but It’s then not possible to use the Cloud+ Sync because the file has the same name and then it’s not possible to use it. And if I gave him another name, I have then two databases, and only the one with less datas get’s synchronized.
    Completely unusable :-(

    Finally I have to say, that it seems to be impossible to use Cloud+ Sync on a save way with Tap Forms. The alternative for me, which is not what I want, is to use Tap Forms only on my iPhone and iPad. But then, I have also to stop my MacOS+iOS subscriptian and use only the iOS subscription. But I need my datas also on the MacBook, so which alternative do I have???

    #54597
    Tom Seputis
    Participant

    Hi Brendan,

    Thanks for the extremely quick response. The whole issue for this formula not working was the curly quotes. I was not aware of how subtle the difference is in the way that they look. Changed to straight quotes and now it all works fine.

    I will have to learn more about scripting if I try anything more complicated than this.

    Thanks Again,
    Tom

    #54596
    Brendan
    Keymaster

    It also starts to get really complicated to diagnose when you have so much nesting going on within the expression. That’s when I switch to a Script field instead of a Calculation field.

    #54572
    Brendan
    Keymaster

    So you’re using the new Conditional Visibility rules to decide to show or hide a field? I don’t think I tested the condition where the value is changed from within a script. I’ll have to look into that. I had just been focused on when you change values using the user interface.

    Also you should only need a single document.saveAllChangesAndRefresh() at the very end of your script, after you make any changes. So that record.refreshCalculations() should go before the save function call.

    #54570
    tekl mister
    Participant

    I’ve a simple form with two date fields (start and end) and some other fields. The first date field is populated with the current date. The second date field is empty. And some fields are hidden until the second field contains a date. To make it easier for the user, I’ve added a button to a Universal layout. When I click the button, the date field should be filled with the current date. I use this script for the task:

    function MyScript() {
        var field_id = 'fld-b64c54dfb3de446fbf2b25b203c90104';
        
        record.setFieldValue(field_id, new Date(), true);
        record.refreshCalculations();
        form.saveAllChanges();
        document.saveAllChangesAndRefresh();
        record.refreshCalculations();
        }
    
    MyScript();

    As you can see, I tried a lot to make the button work. But it doesn’t. After clicking, nothing happens. When I click on an empty area of the form, the second date field shos its content. But the hidden fields are still hidden, I’ve to switch layouts or record to let Tap Forms update the screen.

    Is there a way to refresh the view? Or did I something wrong?

    #54548

    In reply to: Conditional formatting

    Brendan
    Keymaster

    Yes, you can do that already. When you select a Date field on the Conditional Rule editor, you’ll see a popup that lets you select some options for the comparison. Is today is one of the options.

    Right now I just have AI used to generate forms for you based on a form name and description.

    I did play around with trying to get an LLM to do some generic queries based on data in the database, but it didn’t work that well. LLMs don’t seem to handle structured data very well. It’s great for summarizing large blocks of text and pulling out bits of data. But I was trying to ask it questions like “What’s the largest expense paid in the Electronics category?” It failed when using the local LLMs built-in to Apples OSs. And when I tried to get an external LLM to do it, I ended up going over the token limit because it would have to send the entire form’s data to the LLM service and then process the data there. It was just too much data to send.

    I did add a few new shortcuts to Tap Forms Pro 1.4 recently so you could ask it some pointed questions without scripting. Such as Find Records By Field Value and Find Most Common Value in Form in Field, etc.

    #54542
    Brendan
    Keymaster

    Hi Melanie,

    If you could please email me a sample form and script that demonstrates this crash that would really help me to figure it out. Send it to support@tapforms.com

    Thanks,

    Brendan

    #54539
    Brendan
    Keymaster

    Hi Gattopardi,

    I’ll look into that. For now though you could simulate that with a Calculation field or a Script field which returns whatever value you want to distinguish 0’s from nil values. Then just set the Group Records By option to that field.

    But it probably made more sense to me at the time to group nils and 0’s together with the Group Records by function. But I can see how you would want them separate.

    Thanks,

    Brendan

    Gattopardi
    Participant

    Hi Brendan,

    I’ve noticed what seems to be a grouping issue with Number fields in Tap Forms Pro.

    If a Number field contains a value and I delete that value, the field correctly appears empty. However, when I use this field with Group Records By, the record is placed in the 0 group, as if the empty field actually contained the value 0.

    I checked the value with a script:

    var value = record.getFieldValue(‘fld-0de…….’);

    if (value === undefined) {
    return “UNDEFINED — no value”;
    }

    return “VALUE: ” + value;
    For the affected record, the script returns:

    UNDEFINED — no value

    So the Number field really is empty and does not contain 0. It seems that Group Records By is treating undefined and the numeric value 0 as the same grouping value.

    Would it be possible for empty Number fields to remain in a separate empty group, rather than being grouped together with records whose value is actually 0?

    Thanks!

    #54532
    Melanie Schaaf
    Participant

    Hi Daniel,

    Thanks so much for taking the time to look into this and reply; I really appreciate that!

    Your diagnosis lines up with what I found through my own trial and error: I’d isolated the crash to the same spot, a loop combined with a second, differently-shaped Prompter (the null/’label’ confirm dialog alongside the popup one). Good to have that independently confirmed, this makes me more confident it’s a real bug worth Brendan’s attention rather than something odd in my own setup.

    Your scriptHandler/prompterHelper tool looks interesting! Thank you for providing this! I may well come back to it if I want the smoother “pick several at once” experience down the line. For now though, I’ve got a single-shot-per-click version running that avoids the crash entirely, but I might get tired of the extra clicking every time I want to link an additional record. So I’ll definitely keep your library in mind.

    Thanks again for chiming in. Also hoping you or Brendan might actually be able to isolate that underlying bug in future, but this was a great start.

    Best,
    Melanie

    #54531
    Daniel Leu
    Participant

    The issue is in promptConfirm, but I haven’t isolated it yet. I think it’s related to ‘null’ and ‘label’.

    I have a prompter library that implements this function as well. Due to a lack of time, I just used this with your code. You need to install my scriptHandler from https://lab.danielleu.com/tapformspro/script-library/scripthandler.html. This will install the prompterHelper as well which is used by the script.

    document.getFormNamed("scriptHandler").runScriptNamed("prompterHelper");
    
    async function Pick_Subtheme() {
        await pickSubtheme();
    }
    
    async function pickSubtheme() {
        var subthemes = [
            "Episode IV – A New Hope",
            "Episode VI – Return of the Jedi",
            "Classic Star Wars",
            "Lego Star Wars – Ultimate Collector's Series"
        ];
    
        var selected = [];
        var keepAdding = true;
        while (keepAdding) {
            try {
                await picklistPrompter("Pick Subtheme", "Add a Subtheme:", subthemes, subthemes[0]);
            } catch (err) {
                console.log("Cancelled: " + err, "#ff0000");
                break;
            }
    
            var chosen = prompterVar;
            selected.push(chosen);
            console.log("Selected: " + chosen);
            // … link the chosen record …
    
            var again = await yesnoPrompter("Add another Subtheme?", "Add Subtheme", "Done");
            keepAdding = (again === "Add Subtheme");
        }
    
        if (selected.length === 0) {
            console.log("No subthemes selected.");
        } else {
            console.log("Subthemes selected (" + selected.length + "): " + selected.join(", "));
        }
    }
    
    Pick_Subtheme();
    

    Cheers, Daniel

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

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