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

    #54071
    Brendan
    Keymaster

    Hi ADDdb,

    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.

    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.

    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.

    Thanks,

    Brendan

    #54037
    Gary Treible
    Participant

    I created a “parts” database in TFP on Mac. Nominally it contains a part number, description, and an image of the part. Most of the images have been sourced by screen shoting something on the web and pasting it into the picture field. This works fine, and although I’ve made zero effort to worry about size or dimensions of these images, they seen to scale perfectly to the image area in my layout, either by matching the width or the height. Unfortunately, when I”ve created layouts in the iOS app, these images are way too large to be viewed. I can touch them, and see the whole image in the viewer, but not in the layout image box by itself. Is there a way I can get TFP for iOS to automatically scale these images like it (apparently) does on Mac? I would like to simply select a record and see the part, no matter how small it might appear, without having to touch the image to bring up the viewer.

    Thanks,

    Gary (new user)

    Steve-Kai Vyska
    Participant

    I solved a Tap Forms limitation by using a generated technical code to separate linked records by status, even though I could not apply an extra filter directly inside the relationship.

    Example:
    A Unit / Apartment should show

    active Lease Agreements
    archived Lease Agreements
    separately.

    Idea
    Each Lease Agreement gets a calculated field called something like Display Code.

    That code consists of:

    a status prefix
    plus the RecID of the linked unit
    For example:

    A.rec-123… = active agreement
    N.rec-123… = inactive / ended agreement
    Step 1: Expose the unit’s own RecID
    In the Unit form, create a script field that returns the record’s own ID:

    function UnitRecID() {
    return record.getId();
    }
    UnitRecID();
    Step 2: Read the linked unit RecID inside the lease agreement
    In the Lease Agreement form, create a script field that reads the RecID from the directly linked unit:

    function LinkedUnitRecID() {
    var unit;

    unit = record.getFieldValue(‘UNIT_FIELD_ID’);
    if (!unit || !unit.length) {
    return ”;
    }

    return unit[0].getId();
    }
    LinkedUnitRecID();
    Step 3: Build a calculated display code
    In the Lease Agreement form, create a calculated field such as:

    IFEMPTY( Lease End Date ; “A.” ; IF( Lease End Date < TODAY() ; “N.” ; “A.” ) ) + Linked Unit RecID
    Result:

    A.rec-123…
    N.rec-123…
    Step 4: Use separate linked views in the unit
    Now the Unit form can have separate linked fields / subform views for:

    active lease agreements
    archived lease agreements
    Important note
    Do not create new lease agreements through the filtered view.

    Instead, create them through a normal unfiltered subform like:

    All Lease Agreements
    That way the direct relationship to the unit is set first, and the technical fields can calculate correctly afterward.

    This approach worked well for me when I needed different “views” of the same linked records, but Tap Forms could not apply the additional filtering logic directly inside the relationship.

    Perhaps someone need this too.

    C ya

    Steve

    #54029
    Antonino Crea
    Participant

    Great software, but I’m disappointed by the forced move to a subscription model and the lack of a native version for TF5 users. We need a perpetual license option for Apple Silicon.

    #54023

    In reply to: Syncronisation issue

    Brendan
    Keymaster

    Hi Brian,

    No, Cloud+ Sync is not the same as Apple’s iCloud+ subscription service. Sorry for the naming confusion. Cloud+ Sync is just a new algorithm for syncing with iCloud. I wasn’t sure exactly what to call it as an optional, yet separate iCloud sync service.

    So it just uses your own iCloud account the same as the regular iCloud sync service. It’s just more efficient and uses less storage space than the previous version. I didn’t want to just replace the iCloud Sync service with Cloud+ in case people were happy and successfully using the existing one, so I just made it another sync service to choose from.

    Hope that clears it up.

    Thanks,

    Brendan

    #54022

    In reply to: Syncronisation issue

    Brian Quinn
    Participant

    I have just upgraded from Tap Forms 5 to Pro and am synching across 4 devices.
    I am experiencing the same problem as Tom with apparently random non-synching of bits of data.
    Before trying your advice, Brendan, can you just clarify:
    You mention deleting from iCloud and then selecting iCloud+. As I understand it, iCloud+ is a subscription version. Are you really saying we need to take out an iCloud+ subscription to try to solve the synching problem?

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