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 - 976 through 990 (of 2,951 total)
  • Author
    Search Results
  • #46577
    Stig Widell
    Participant

    Hi,
    Is anyone willing to help a Swedish farmer with a record script in his cow data base?
    No knowledge in JavaScript!
    Brendan Duddrige has helped a lot with two earlier scripts but is too busy now for a third one.
    Will send document via e-mail.
    Regards
    Stig Widell

    #46574
    Rob Naaijkens
    Participant

    I have a series of records with a Table Field. I would need to use their total value in a second form. Is it possible with scripting? And if so, what is the way to do this?

    #46571
    Prashant M
    Participant

    Dear Daniel , I will definitely use back-ticks and link to the post

    Thanks for the script , It works properly on my OSX also when I try to use the same on iPhone manually it works (via Scripts->RUN)

    BUT if I add the script to Siri Shortcuts , I simply get a DONE message and no prompt to enter. Please see screenshot attached for the same.

    Dear Sam, Thanks for the link , I’ve installed the same on OSX , and I see 19 scripts :) I will be studying these and updating !

    Attachments:
    You must be logged in to view attached files.
    #46564
    Sam Moffatt
    Participant

    I also have some Prompter Functions in the Script Manager that might help you as well. Same note as Daniel that your calling function needs to be declared async to use these.

    #46561
    Prashant M
    Participant

    This is my first Script Trial , so apologise for my n00bs qs

    There are multiple prompter scripts floating on forum but I don’t know which one to pick up. I’ve tried to patch together adding a simple record in site_id but it fails

    var site_id = ‘fld-790b9d32090d4fd1873119a3e6401ec6’;
    function textPrompter(title, text=””) {
    return new Promise(function(resolve, reject) {
    let prompter = Prompter.new();
    prompter.cancelButtonTitle = ‘Cancel’;
    prompter.continueButtonTitle = ‘Continue’;
    prompter.addParameter(text,’prompterVar’)
    .show(title, ((status) => {
    if (status == false || prompterVar == undefined) {
    reject(‘Cancel’);
    } else {
    resolve(prompterVar);
    }
    }));
    });
    }

    var newRecord = form.addNewRecord();
    newRecord.setFieldValue(site_id, prompterVar);

    textPrompter();

    #46557
    Daniel Leu
    Participant

    It is not that complicated! This is a form script that loops through all records. It reads that value of your note field, modifies it, and then writes it back. Additionally, it checks that the note field content is defined, otherwise further processing is skipped.

    The script currently replaces all line-breaks with a whitespace and removes all leading and trailing whitespaces. As you see, you can use your regex in JavaScript as well :)

    The only change you need to make is define the note_id constant according to your form script. There are several ways to get the id. One way is to click on the field name in the script editor, then select and copy the ID string that is displayed underneath all the field names.

    function Remove_Spaces() {
    
       const note_id = 'fld-xxx' // set note_id according to your form
    
       for (let rec of form.getRecords()){
    	
          // get note field
          let note = rec.getFieldValue(note_id)
          console.log("Orignial note: " + note)
    
          // Check that note is defined
          if (note) {
             // modify note (replace line breaks with
             // whitespaces and remove whitespaces from
             // both ends of string
             let modifiedNote = note.replace(/\n/g, " ").trim()
    			
             console.log("Modified note: " + modifiedNote)
    	
             // save note field
             rec.setFieldValue(note_id, modifiedNote)
          }
       }
    	
       document.saveAllChanges()
    }
    
    Remove_Spaces()
    • This reply was modified 3 years, 9 months ago by Daniel Leu. Reason: replaced tabs with ' ' for better readability
    • This reply was modified 3 years, 9 months ago by Daniel Leu.
    • This reply was modified 3 years, 9 months ago by Daniel Leu.

    Cheers, Daniel

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

    #46551
    Brendan
    Keymaster

    You would probably need to write a Form Script that looped through the records then fetched the values for the fields you want to trim and then use the JavaScript trim() function.

    #46520
    Sam Moffatt
    Participant

    You can do this with a script field and the “child records loop” snippet applied to the field you’re interested in joining together. If you search the forum for “child records loop” you can find some similar examples and the intro to scripting video I did also covers using the child records loop to create a comma separated list.

    #46511
    Prashant M
    Participant

    Our office uses QuickBase as DB , low code application. One of it’s cool features is to summarise the linked records in parent table. Please see screenshot attached.

    This feature can make exporting Linked Records much easier in one single excel or if Tap Forms already can do using script , please advise me

    Attachments:
    You must be logged in to view attached files.
    #46503
    Sam Moffatt
    Participant

    You have two parseDate methods and one will likely mess with the other somewhere. You will need to give them independent names and usually extract them at the top of the script (this is what Daniel was referring to). Perhaps name one parseDate and the other parseTime to reflect that it’s handling a time.

    If you look at the earlier script I posted, I had parseDate prior to the Import_Passport method. If you do something similar with the parseDate and renamed the other one parseTime, it’ll make it a little easier to read and I think should fix the error you’re getting.

    #46502
    Sam Moffatt
    Participant

    1. Conceptually instead of adding the photos to Tap Forms and leveraging the built in functionality which would copy the photo into the document, you upload it to a third party service like S3 that then hosts the file. That gives you a link to the file that you can then include in a website field within Tap Forms. If you have many photos of the same item, I’d suggest that you use a table field where each image file you upload to S3 becomes an entry (Daniel does this and posted one script on opening attachments easily from a table). The image hosting service is somewhat immaterial, so long as you get a link to navigate to it that works on all of your devices. I picked S3 because there are plenty of resources out there on getting started with S3 and it’s relatively inexpensive all told.

    2. Yes, a single user with the macOS version of TF running on a single device can use the feature of the attachment field that allows you to do an “add file alias” which doesn’t trigger a copy of the file into the document however this doesn’t work properly when you move to another Mac and obviously can’t work on iOS. That said in the NAS use case if they don’t have concurrent editing on the NAS, it would probably be ok for it to be shared on the NAS rather than use sync directly but there are not protections against concurrent editing so it could ultimately end up corrupted.

    This is I think the second or maybe third post recently where this has been raised but adding such a feature is non-trivial so might be something for a later version (TF6?) as it would require rethinking a little how attachments (photos and files in general) are stored and maintained. iCloud could also be an answer as well because I think it has blob storage though obviously that limits cross-user sharing as well plus is one of the more expensive platforms (plus you can only buy 2TB off them).

    #46499
    Chris Ju
    Participant

    I have two issues, i can’t solve:

    I have two forms (F1 + F2) and i’m importing via script from csv file. With F1 all fields with dates (e.g. 13.01.2022) are fine using Sam’s function parseDate. But in F2 it doesn’t work. Same format as above and it says “undefined”. What the hell?

    The second issue i have is with time fields. The import file has entries with time stamps (e.g. 17:43:56). Could these fields also be handled as dates? Is there a similar function?

    Thanks for your help…

    #46494
    Sam Moffatt
    Participant

    On iOS when you have a record open you can do “Copy Record Link” via the hamburger menu on the top right to take you back to that record. On the Mac, “Copy Record Link” is under the Edit menu.

    The format is tapformz://record/view/[database ID]/[form ID]/[record ID]. The database ID is a unique identifier for your document, form ID is the internal identifier for the form and similarly record ID for the record. In addition to being able to use the UI to get the values, you can also use record.getUrl() via the Scripting API to chain actions together, embed into logs or use in field scripts. The JavaScript API also covers the ability to call into scripts in Tap Forms from external applications as well which gives you the ability to trigger form scripts with custom data. I have a video on how you can use this to integrate with Siri Shortcuts with barcode scanning of packages as a use case.

    #46492

    In reply to: Updated Script Manager

    Chris Ju
    Participant

    Sam, thank you very much for your script manager. It’s very cool! Have you ever considered including PapaParse? I think MIT-License allows that (https://mit-license.org)…

    #46486
    Chris Ju
    Participant

    Great thanks to Brendan and Sam also from me for that script help… I had also this date issue and that date parse function works great!

    BTW: Is ist possible to get the home directory name?

Viewing 15 results - 976 through 990 (of 2,951 total)