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

    In reply to: Greetings from France,

    Luc VIENNE
    Participant

    Hello Bredan,

    No, I don’t want to stay on a particular version of macOS because of one piece of software. No, I don’t want to pay such an expensive subscription.

    yes, I understand that you spent a year developing the PRO version; no, I don’t understand why you can’t disable the PRO features to make a lighter version, or else there’s a catch (as we say in France) and the PRO version is just the original version rewritten, which certainly required a lot of work.

    So unfortunately, I see that you’re not open to other suggestions, so I’m going to leave you for other, less expensive applications.

    I hope you succeed, but I have my doubts… Thank you for replying and reading. Cheers. Luc

    #54132
    Steve-Kai Vyska
    Participant

    Thanks for the suggestion.

    I tested this with a script that writes values into the related subform records.

    The script fills/updates the subform records without calling refreshCalculations() on those child records. After calling saveAllChangesAndRefresh(), the new values are visible in the subform, and the calculation fields inside the subform records are updated correctly.

    So this part works as expected.

    The remaining issue is the parent record.

    The parent record has a calculation field that depends on the calculation results from the related subform records. These subform calculation values are already correct and visible, but the parent calculation field still does not update.

    I also tried the recommended call on the parent record:

    
    function Test() {
        record.refreshCalculations();
    }
    
    Test();

    Unfortunately, this does not change the parent calculation either.

    So the subform records and their own calculations are refreshed correctly. The problem is that the parent record does not seem to recalculate based on the updated subform calculation values, even after calling refreshCalculations() on the parent record.

    Have a nice Sunday

    Steve

    #54131
    Daniel Leu
    Participant

    Following field script should do the trick. It assumes that the field name is photo. Don’t forget to set the return type of the field script to date.

    
    function First_Photo_Date() {
        // set field name according to your form
        var photo_id = form.getFieldNamed('photo').getId();
    
        // get attached photos
        const photos = record.getFieldValue(photo_id);
    
        // get first photo's date
        const photoExif = photos[0].getExifData(photos[0]);
        const photoDate = photoExif['DateTimeOriginal'];
    
        // handle Exif date format
        const [datePart, timePart] = photoDate.split(" ");
        const [year, month, day] = datePart.split(":").map(Number);
        const [hour, minute, second] = timePart.split(":").map(Number);
    
        // create date object
        const date = new Date(year, month - 1, day, hour, minute, second);
        
        return date;
    }
    
    First_Photo_Date();
    

    Cheers, Daniel

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

    #54130
    Daniel Leu
    Participant

    Yeah, I got used to this behavior. If you create or update the child record from a script, run childRecord.refreshCalculations() once you have populated it with your values.

    Cheers, Daniel

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

    #54123
    Luc VIENNE
    Participant

    Dear Bredan,

    I know you’ve already answered this question, but I’d like to reiterate.

    I’ve been using your fantastic TapForms 5 for years to manage the software I use and those I’ve tried that didn’t suit me. I have about 300 records: not a huge number, but incredibly useful for me, as my memory is failing me a bit and I sometimes forget what a particular program does. I’m retired and don’t have a lot of money; so I don’t like subscriptions, but I’m willing to pay for an upgrade to an Apple Silicon version while keeping the same features.

    I haven’t seen what the PRO version would offer me, and I don’t want to (can’t) pay that much. Yes, it’s great for businesses, but for an individual, it’s a different story.

    I would like you to reconsider your position and offer us a “light” version of your PRO (with the current features) so we don’t have to completely rewrite the standard version.

    As you can see, I’m spending time writing to you and making suggestions; if I can help, I have some time, but not much money, and I think many of us are in the same boat. Perhaps you could conduct a survey, since you have all our email addresses.

    I’m sure you’ll appreciate this request;
    so, it would be fantastic if you could respond favorably.

    Thank you in advance. See you soon. Luc

    #54120
    FrAnksch
    Participant

    Can anybody give me a script that reads the EXIF date of a photo (used in field “photo”) and puts this date to an separate field “date”?

    I want the entries to be ordered by the date of the photos, that are used in the records.

    THABK YOU!

    #54108

    In reply to: User-Agent header

    David Schwane
    Participant

    Thank you so much. Fortunately I am using Pro. My dumb AI scripting buddy was using the 5.3 API reference. It is working now.

    #54103
    Daniel Leu
    Participant

    Hi Andrew,

    1) You really just need the ‘fld-xxxxx’ section from the code Tap Forms Pro inserted. You could rename the variables to make it more readable, but that’s not necessary.

    2) When you create a new field script, I would remove the default code. But javascript supports the structure you wrote (as far as I can tell).

    Here’s the code with your field ids:

    // From a linked form, fetches all values for a given field. 
    function getLinkedFieldValue(link_id, link_num, linked_field_id){
         const linkedRecs = record.getFieldValue(link_id)
    
         if (linkedRecs) {
            linkedValue = linkedRecs[link_num].getFieldValue(linked_field_id)
            if (linkedValue){
                return linkedValue;
            }
        }   
    }
    
    function main() {
        const childForm_id = 'fld-42f52b4ec1ca4514ac86af90d8d6e718';
    
        const child__name_id = 'fld-9d0490166c594a34bc8e8f9967510f4f';
        const childNum = 0; // first child selected
    
        const childName = getLinkedFieldValue(childForm_id, childNum, child__name_id);
        if (childName){
            return childName;
        }
    }
    
    main();
    

    Cheers, Daniel

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

    #54101

    Topic: User-Agent header

    in forum Script Talk
    David Schwane
    Participant

    Hi,

    I’m trying to connect to the Discogs API, and my AI scripting buddy tells me “The failure likely occurred because the Discogs API strictly requires a User-Agent header, which Tap Forms Pro cannot currently send through its built-in Utils methods”.

    Any suggestions to help on this?

    reference: https://www.discogs.com/developers
    Your application must provide a User-Agent string that identifies itself – preferably something that follows RFC 1945.

    #54089
    Daniel Leu
    Participant

    What you’re after can’t be done in calculation fields. You need to use script fields. Here’s a small sample script that returns the value of a given field.

    // From a linked form, fetches all values for a given field. 
    function getLinkedFieldValue(link_id, link_num, linked_field_id){
         const linkedRecs = record.getFieldValue(link_id)
    
         if (linkedRecs) {
            linkedValue = linkedRecs[link_num].getFieldValue(linked_field_id)
            if (linkedValue){
                return linkedValue;
            }
        }   
    }
    
    function main() {
        const childForm_id = 'fld-588ffa6326894f809eee01372e96755a';
    
        const child__name_id = 'fld-921163e2400545898782e744e6a79750';
        const childNum = 0; // first child selected
    
        const childName = getLinkedFieldValue(childForm_id, childNum, child__name_id);
        if (childName){
            return childName;
        }
    }
    
    main();
    

    Now you only need to set the field ids for the link field and the child field. You can get them in the script editor by selecting the name of the field in the left side column, then click on the ID button.

    Two concatenate several values, you can use following

        const childFirstName = getLinkedFieldValue(childForm_id, childNum, child__firstName_id);
        const childName = getLinkedFieldValue(childForm_id, childNum, child__name_id);
    
        return childFirstName + ' - ' + childName;
    

    It will take a bit more time than just selecting a field in a popup, but using Tap Form Pro’s powerful JavaScript API, you can accomplish many tasks. Oh, don’t forget to set the return type according to your field type.

    Hope this helps!

    Cheers, Daniel

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

    #54085
    ADDdb
    Participant

    Hi @Brendon

    1. A Form is equivalent to a Table in common database language. Within each Form there are Fields that comprise the types of data you want to capture (think of different columns in a spreadsheet). And each Form can have as many Records as you like to store the information in the fields.

    That makes sense. Thanks

    2. Your screenshot doesn’t show the parent form, so I don’t know how you have it setup. But you can’t really display a single field or value from a Many to Many relationship. That’s because with a Many to Many relationship, there can be many fields and many rows in that relationship. Tap Forms does allow you to generate aggregate calculations for Number fields from a formula though.

    I’ve attached updated parent and child forms and the Record ID field (previously called File Name) calculation.

    The child form, Counterparties shows two records (Coles and Energy), but on the parent form in the one record I have selected one record from Counterparties (Energy).

    Perhaps I could elaborate on what I am trying to do and compare this to how it works in AirTable which might help to establish if and how (or if not) this can be achieved in TFP?…

    My objective is to maintain a child form (Counterparties form) with many fields pertaining to counterparties. On the parent form (Documents), one of the things I want to show for each relevant record is a selected counterparty name from the child form (the option exists to show more that one per parent form record, but in this case I just need one). I also want to show for that parent record two other fields from the child form that pertain to that particular counterparty, but I don’t want to see all of the many fields from the child form repeated in the parent form.

    In AirTable in the parent form (Documents) in a new field (Counterparty) I would link to another form, by selecting that form in a dropdown. I could then select a record in this new field in the parent form, and a dropdown in that field would allow me to link to a particular record in the child form. The record ID selected in the child form would then appear in the field in the parent form. The record ID comes from the left-most field in a form, in this case the child form.

    This appears to be similar to what I have achieved in TPF in the table appearing to the right of the Counterparty field in the single column view in the parent form (in this case I selected Energy).

    In AirTable, I can then create new fields in the parent form to show other fields from the child form (AT calls them a Lookup); in this case I want two more. So in total there would be three fields in the parent form drawing from the child form: the link to the record ID (Counterparty) and two others (say, Address and Phone No.), but in this case I don’t want to see Counterparty Logo and so I don’t select that one.

    I then want to create a left-most ID field (Record ID) in the parent form that concatenates certain fields in that form, in this case Counterparty (which would ideally be the Counterparty Name from the child form) and Legal Briefs (the latter being a text field in the parent form). Note that I am trying to do that using the Calculation function (but perhaps that is wrong).

    Attempting to do this in TFP, I see in the parent form that the Counterparty field is linked to the Counterparties forming a many to many relationship with inverse relationships shown. In the multi-column view at the top nothing is shown (which surprises me). In the single-column view underneath in Counterparty field there is a a table which shows two of the four fields in the Counterparties child form. I’m not sure why two of four only appear, but I really need only one for my use case: Counterparty Name and I have successfully selected one record: Energy (but as noted it doesn’t appear at the top under the Counterparty field (?)).

    After trying my formula (“calculation”) and the recommendation from @Chris Richardson I cannot get anything to appear in the Record ID. What I want to show is [Counterparty]-[Legal Briefs], for example the second record might show the same counterparty with a legal brief no. 2.

    So I am stuck on this as well.

    If you need more advanced access to the rows and fields in a Link to Form field setup as a Many to Many relationship, then you’ll need to use JavaScript with a Script Field or Form Script that lets you loop over the records of the relationship and pick out the data that you want to display on the parent form.

    Ok. If that is the only way to achieve what I am after then I would investigate that. I’d appreciate confirmation or otherwise that based on my long explanation above, that scripting is the only way before embarking on that (and considering whether it is a route I want to pursue given how easy it is in AT and scripting sounds like more work(?)).

    Many thanks

    Attachments:
    You must be logged in to view attached files.
    Daniel Leu
    Participant

    Brendan enhanced the API over the years and file handling was improved in Tap Forms Pro: Utils.writeTextToUrl(text, fileUrl). So you can do const status = Utils.writeTextToUrl('Hello world!', 'file:///Users/daniel/Desktop/test.txt');. Please note that fileUrl path must enabled using the Script Access Folder setting.

    Cheers, Daniel

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

    #54078
    Steve-Kai Vyska
    Participant

    Hi Brendan,

    I must admit, that I have never realized this little field down there and of course it was set to TEXT 🤦‍♂️ Yes it is working now. In the meanwhile I have build a working Rent-Administration system with your Tap Forms pro and it is working really really good Thanks for the good work you are doing here making it a great product 👏

    I really must say that in the whole system there are little work arounds you can use to make it all Work as you want. But one Think is missing 😂 Write something to a normal text File via script 😂 actually I’m using the copyTo Clipboard and put it via Editor in the file bat that would be the last missing Part for me 👍

    Have a nice Weekend 🙋‍♂️

    Brendan
    Keymaster

    Hi Steve,

    Make sure you set the Result Type of your Script Field to Number (bottom-left of the Script Editor window).

    Then the formatting options should work.

    Thanks,

    Brendan

    Steve-Kai Vyska
    Participant

    Hi Everyone,

    I may have found a problem with Script Fields and number formatting in Tap Forms Pro.

    I have a Script Field in a form that returns a numeric value from JavaScript.
    I tested different variants, for example:

    – returning a parsed integer directly
    – returning a rounded number
    – returning a plain numeric value without formatting

    Example idea:

    return 12050;

    The field settings are:

    – Number Format: Currency Accounting
    – Currency: Czech Koruna
    – Decimal Places: 2

    My expectation was that Tap Forms would display the returned numeric value using the field’s configured formatting, for example with the correct currency/accounting display.

    But the formatting does not seem to be applied as expected.
    It looks like the Script Field output is shown more like a raw value than like a properly formatted currency field.

    I also tried simplifying the script as much as possible, so this does not seem to be caused by custom formatting logic inside the script itself.

    Question:
    Is this expected behavior for Script Fields?
    Or should a Script Field that returns a numeric value inherit and display the configured number/currency formatting of the field?

    If needed, I can provide a minimal reproduction example.

    Thanks!

    Steve

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