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 - 301 through 315 (of 2,950 total)
  • Author
    Search Results
  • #51008

    In reply to: Custom Number Fomats

    Daniel Leu
    Participant

    Lorenzo, have a look at the attached document. It shows you how to convert a weight unit from metric to imperial and vice-versa. Each input field you want to convert needs a corresponding formatter field which is a field script. This script uses a common form script to perform the conversion.

    In the past, I already did a fraction converter, so I thought that this is a nice exercise to build upon that.

    Hope this helps!

    -Daniel

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

    Cheers, Daniel

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

    #50997

    In reply to: Sum selection?

    JScottA
    Participant

    Good morning. Here is what the Tap Forms Assistant provided:

    To address the user’s request regarding summing selected entries from a numeric column in Tap Forms without needing to create multiple calculations:

    1. **Selecting Multiple Entries**: Tap Forms itself doesn’t directly allow summing only selected entries through its standard interface without scripting or creating calculations. However, there are workarounds depending on your workflow.

    2. **Using Filters**: One approach could be to use Tap Forms’ filtering and grouping functionality to narrow down your dataset to just the entries you want to sum. Once filtered, you could use the summary calculation options that display totals at the bottom of the list view (available in Multi-Column view).

    3. **Scripting**: If you frequently change the range of entries you want to sum, a more flexible solution would involve scripting. You could write a JavaScript function within Tap Forms that allows you to select different ranges or criteria and then dynamically sum the values. This script could be easily modified each time you need a new sum.

    4. **Summary Calculation**: For a non-scripting approach, if you have a common range of entries you select often, you could set up multiple summary calculations within Tap Forms. These could be pre-set for various ranges and simply toggled on or off as needed.

    For a deeper dive into summary calculations, see page 29 of the Tap Forms manual, which discusses the summary options available, including summing, averaging, and counting entries within a field.

    If you’re interested in the scripting approach, the Tap Forms Scripting 101 guide online would be a good place to start to create a custom script tailored to your needs.

    If you need further assistance setting up any of these methods or want more details on scripting, let me know!

    #50996

    In reply to: Sum selection?

    Daniel Leu
    Participant

    How about using savedSearch? Usually, I add a checkmark field to each record and use a savedSearch on this field.

    For whatever I want to do, I select the records in question, then go to the saveSearch with checkmark=1 and have just these records. Now you get the sum for the records.

    Additionally, I’ve a form script to clear the checkmark fields.

    Cheers, Daniel

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

    #50976
    JScottA
    Participant

    FYI…pasted Vitor’s original post into the assistant GPT. For the record, I liked Brendan’s very concise and to the point response better, for my typical requests. Anyway, here is the complete GPT response:

    To display numbers with two decimal places in your Tap Forms script, you can use JavaScript’s toFixed() method. Here is your script modified to ensure that numbers are formatted to always show two decimal places:

    `javascript
    function Third_Party_Charges_Csv() {

    // Fetch content from table
    var third_party_charges = record.getFieldValue(‘fld-021cfb3cc4f446ddbf5f9463c7b5d620’);

    // Define field ids from table columns
    const item_id = ‘fld-410bdf5d624a4651b8a803becd9c6578’;
    const cost_per_item_id = ‘fld-6cea4aa73ad44b6f91ba7f566e321790’;
    const number_id = ‘fld-95791fbc24bd4f3ca714756e5dd6a060’;
    const cost_id = ‘fld-a0be1b009c6a4a99a1784d36da134ee3’;

    var txt = [];

    // Loop over all entries and fetch field content.
    for (var n = 0; n < third_party_charges.length; n++){
    var third_party_charge = third_party_charges[n];
    var item = third_party_charge.getFieldValue(item_id);
    var cost_per_item = parseFloat(third_party_charge.getFieldValue(cost_per_item_id)).toFixed(2);
    var number = parseFloat(third_party_charge.getFieldValue(number_id)).toFixed(2);
    var cost = parseFloat(third_party_charge.getFieldValue(cost_id)).toFixed(2);

    // Format field content as desired
    txt.push((n+1) + “. ” + item + “: £” + cost_per_item + ” x ” + number + ” = £” + cost);
    }

    // Combine each formatted table row
    return txt.join(” – “);
    }

    Third_Party_Charges_Csv();
    `

    By using parseFloat() and toFixed(2), this script ensures that the cost_per_item, number, and cost fields are always displayed with two decimal places [oai_citation:1,javascript – Format number to always show 2 decimal places – Stack Overflow](https://stackoverflow.com/questions/6134039/format-number-to-always-show-2-decimal-places) [oai_citation:2,javascript – How to format numbers? – Stack Overflow](https://stackoverflow.com/questions/5731193/how-to-format-numbers).

    #50967
    Victor Warner
    Participant

    I have a script where several fields are concatenated together including one which contains a number:

    
    function Third_Party_Charges_Csv() {
    
    // Fetch content from table
    var third_party_charges = record.getFieldValue('fld-021cfb3cc4f446ddbf5f9463c7b5d620');
    
    // Define field ids from table columns
    const item_id = 'fld-410bdf5d624a4651b8a803becd9c6578';
    const cost_per_item_id = 'fld-6cea4aa73ad44b6f91ba7f566e321790';
    const number_id = 'fld-95791fbc24bd4f3ca714756e5dd6a060';
    const cost_id = 'fld-a0be1b009c6a4a99a1784d36da134ee3';
    
    var txt = [];
    
    // Loop over all entries and fetch field content.
    for (var n = 0; n < third_party_charges.length; n++){
    var third_party_charge = third_party_charges[n];
    var item = third_party_charge.getFieldValue(item_id);
    var cost_per_item = third_party_charge.getFieldValue(cost_per_item_id);
    var number = third_party_charge.getFieldValue(number_id);
    var cost = third_party_charge.getFieldValue(cost_id);
    
    // Format field content as desired
    txt.push((n+1) + ". " + item + ": £" + cost_per_item + " x " + number + " = £" + cost);
    }
    
    // Combine each formatted table row
    return txt.join(" - ");
    
    }
    
    Third_Party_Charges_Csv();
    

    In the field it displays (as currency) as, eg 32.40, but in the script it shows as 32.4.

    Is there a way to make the script show numbers with two decimal places?

     

     

     

    • This topic was modified 1 year, 3 months ago by Brendan.
    • This topic was modified 1 year, 3 months ago by Brendan.
    #50963

    In reply to: Movie Library Template

    David Schwane
    Participant

    I did add the API values to the script.  And I can see the data echoed back in the console log.  I’ve tried a few different movies.

    When I get some time, I’ll try to debug, but thought I’d check to see if an update was already done.

    thanks for replying.

     

    #50962

    In reply to: Movie Library Template

    Brendan
    Keymaster

    It’s possible not all the data is provided from the API that the script is expecting. Did you put in your API ID values into the script?

    #50961
    JScottA
    Participant

    You are welcome, Daniel. I’m no expert on scripting Tap Base. I use it for doing a variety of data science stuff…nothing that requires scripting. I hope the custom GPT does provide some help. Sometime this week I’ll review the priming and see where I can improve it. If anyone hears of any updated manuals or additional Tap Form documents that I can add to the GPTs knowledge, let me know and I’ll see about processing it for including.

    I’m very interested in seeing where Tap Forms goes in possibly supporting Apple Intelligence. I think it might be very useful to professionals and small business to have access to a database that Apple Intelligence could access for its own knowledge. The most immediate impact, in my mind, is using Tap Forms like a local AirTable and combining it with Shortcuts/AppleScript to create powerful automation workflows.

    Until then, I’ll keep this GPT up and running. ;-)

     

    #50960
    Daniel Leu
    Participant

    Looking at the ChatGPT recommendations:

    – In the “Patients” form, create a corresponding table field that can hold the linked medications data. You can configure this table to fetch and display the medications from both “First visit” and “Follow-up visit” forms.

    No such feature for table fields exists.

    4. **Populate the Data:**
    – When you enter data in the “First visit” or “Follow-up visit” forms, you can use the link field to select the relevant patient from the “Patients” form.
    – Enter the medications prescribed in the table fields for each visit.

    To me, more natural would be to start with the “Patients” form and add a “First visit” or “Follow-up visit” record and then populate the respective fields.

    5. **View the Data in the Patients Form:**
    – In the “Patients” form, you will be able to see the linked records from both the “First visit” and “Follow-up visit” forms. The table fields will display all medications prescribed across different visits.

    Note that the table fields of the “First visit” or “Follow-up visit” are only visible when visiting the respective records and are not visible in the ‘linked records’ table.

    The proposed approach doesn’t provide a working solution, but at least it shows the basic setup.

    In the past, I already used ChatGPT to write scripts. By knowing what I need and having an idea how the script should look like, I was able to guide ChatGPT to a working answer. Maybe with this customized ChatGPT instance I can get better results faster. Got to try this!

    Thank you for setting the custom ChatGPT up, Scott!

    Cheers, Daniel

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

    #50955
    JScottA
    Participant

    Using the Tap Forms 5 Assistant (a custom GPT that is not officially supported or endorsed by Brendan) I got the following response by pasting in your post:

    To achieve the goal of having medications prescribed during either the first visit or a follow-up visit show in the “Patients” form, you can utilize the “Link to Form” field type in Tap Forms. Here are the steps to set this up:

    1. **Create the Link to Form Fields:**
    – In each of the forms “First visit” and “Follow-up visit,” add a new field of type “Link to Form” and link it to the “Patients” form. This creates a relationship where records in “First visit” and “Follow-up visit” can be associated with records in the “Patients” form.

    2. **Link Medications to the Patients Form:**
    – In the “First visit” and “Follow-up visit” forms, create a table field to store the medications prescribed. This table field can be populated with medication details for each visit.
    – In the “Patients” form, create a corresponding table field that can hold the linked medications data. You can configure this table to fetch and display the medications from both “First visit” and “Follow-up visit” forms.

    3. **Set Up the Relationships:**
    – When creating the “Link to Form” field, ensure that you enable the “Show Inverse Relationship” option. This will create a corresponding “Link from Form” field in the “Patients” form, enabling you to see which “First visit” or “Follow-up visit” records are associated with each patient.

    4. **Populate the Data:**
    – When you enter data in the “First visit” or “Follow-up visit” forms, you can use the link field to select the relevant patient from the “Patients” form.
    – Enter the medications prescribed in the table fields for each visit.

    5. **View the Data in the Patients Form:**
    – In the “Patients” form, you will be able to see the linked records from both the “First visit” and “Follow-up visit” forms. The table fields will display all medications prescribed across different visits.

    For more detailed instructions, you can refer to the section on creating and managing relationships between forms in the Tap Forms documentation, specifically pages 91-94, which cover the “Link to Form” and “Link from Form” fields and how to use them to create one-to-many and many-to-many relationships.

    By following these steps, you will be able to enter medications in the “First visit” and “Follow-up visit” forms and have them visible and modifiable in the “Patients” form, achieving the desired outcome.

    For additional details, you can also explore the scripting capabilities of Tap Forms if you need more advanced customization: [Tap Forms Scripting 101](https://www.cattail.nu/tap_forms/tap_forms_scripting_101/index.html).

    References:
    – Tap Forms Documentation, pages 91-94.

    Hopefully this is helpful.

    Cheers!

    Scott

    #50925

    In reply to: From Tap Forms to JSON

    Daniel Leu
    Participant

    Another option is to use the Javascript API to create a JSON record. You can use the clipboard to exchange data with another application. Writing to a file is not supported by the Javascript API. If you have an URL listener, than that would be an option too.

    I have a simple example script to copy a record to another Tap Forms document: https://lab.danielleu.com/blog/copying-record-data-between-documents/. This can be extended to copy all records instead of just one.

    Cheers, Daniel

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

    #50903
    Daniel Leu
    Participant

    You could use Utils.postContentToUrlWithContentType() or Utils.postJsonToUrl() to post content to your server. Both API functions are documented in https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api.

    Cheers, Daniel

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

    #50901
    Brendan
    Keymaster

    Hi David,

    You could do this with a Script Field. Something like this:

    function Sortable_Title() {
    var title = record.getFieldValue('fld-3b1b39ccf20f43e583fe66b8aaa0602c');
    var sortableTitle;
    
    if (title.startsWith('A ')) {
    sortableTitle = title.substring(2);
    
    } else if (title.startsWith('An ')) {
    sortableTitle = title.substring(3);
    
    } else if (title.startsWith('The ')) {
    sortableTitle = title.substring(4);
    
    } else {
    sortableTitle = title;
    }
    
    // console.log(sortableTitle);
    
    return sortableTitle;
    
    }
    
    Sortable_Title();
    You could enhance it to support other article words if you like.
    Thanks,
    Brendan
    • This reply was modified 1 year, 4 months ago by Brendan.
    #50897
    Fabio Puissant
    Participant

    Hi, I am quite new to Tap Forms. I wanted to know, since using JavaScript is an option, if you are able to use fetch (or another JS API) to make an HTTP Request.

    I have a client using tap forms 5 and has some renewal_date column. I wanted to automate sending out emails on this renewal date. I wrote a script already to find records that are passed the renewal_date. Now, I have a webhook expecting some record data (email, client_No, renawal_date, …). I would like a way to make an HTTP request to my webhook providing the record data saved in tap form.

    Could anyone advice me please as I don’t find a way to do it. Is this even possible in TapForm??

    Many thanks!

    David Gilbert
    Participant

    There is at least one previous post about this topic, to get records not to sort by articles, where writing a script is suggested.
    I have a music title database with titles in many languages, so getting the sorting right is important. I’m thinking of setting up two fields, a display title and a sorting title. The records would sort by the sorting title:
    Étoile
    Jahsager
    Man in the High Castle

    But the form would only include the display title, and so the sort would appear like this.
    L’Étoile
    Der Jahsager
    The Man in the High Castle

    Not like this:
    Der Jahsager
    L’Étoile
    The Man in the High Castle

    It’s a lot of work to do this obviously, so I’m checking to make sure there is no other easy solution. Also, I guess this will work?
    Muchas gracias,
    David

Viewing 15 results - 301 through 315 (of 2,950 total)