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,141 through 1,155 (of 2,951 total)
  • Author
    Search Results
  • #45407
    Daniel Leu
    Participant

    Please see Sam’s answer to fix your error: https://www.tapforms.com/forums/topic/script-for-find-and-modify-records/#post-45401

    Cheers, Daniel

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

    #45406
    Victor Warner
    Participant

    Thank you for the responses.

    I would be grateful for a simple illustration how to use Utils.getTextFromUrl with a CSV file stored on a computer, how to parse the CSV, and then save the elements to different fields in a form.

    Since I can only do the most basic things with JavaScript I am not sure how even to begin a script such as this.

    #45399
    Fernando DS
    Participant

    Ok. Thank you everybody for your kind answers. This is what I have done in the script and the error that appears in the console.

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

    Have a look at Sam’s videos such like this one: https://www.youtube.com/watch?v=xB1XZyBYNd4&ab_channel=pasamio. You will see the field id about 4 minutes into the video. He has many more on TapForms and scripting on his channel. It is worthwhile to check them out.

    T.L. Ford wrote a scripting 101 as well: http://www.cattail.nu/tap_forms/tap_forms_scripting_101/index_tap_forms_interface.html

    Cheers, Daniel

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

    #45395
    Daniel Leu
    Participant

    The easiest way to get the field ID is to double click on the field name in the script editor. Or you can click on the field name and the select the “ID” field.

    Cheers, Daniel

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

    #45393
    Fernando DS
    Participant

    Ok. I understand the curly and straight quotes. But I can’t find the field id. Neither the script editor, nor beneath the field lost on the property panel. Sorry, I must be very incompetent. I’m using an iphone, I have not got a Mac. Perhaps the problem is this? Thank you very much for your time and patience.

    #45390
    Brendan
    Keymaster

    var fieldId = ‘fld-fieldid’;

    Because first of all, you’re using curly quotes. They need to be straight quotes.

    Plus Tap Forms generates random field IDs. fld-fieldid will never be the field ID that Tap Forms generates. That was just a sample value Sam put in there. You need to change it to be your actual Field ID which you can get from the Script Editor or just beneath the Fields list on the field property panel.

    #45387
    Fernando DS
    Participant

    Hi Brendan,

    The script is as follows:

    function Buscar_Y_Modificar() {

    function Replace_Metal() {
    var fieldId = ‘fld-fieldid’;
    for (var record of form.getRecords()) {
    var fieldValue = record.getFieldValue(fieldId);
    if (fieldValue.includes(“rock duro”)) {
    record.setFieldValue(fieldId, fieldValue.replace(“rock duro”,
    “heavy metal”));
    }
    }
    form.saveAllChanges();
    }

    Replace_Metal();

    Replace fld-fieldid with a field ID from either the script editor or
    find it in the field editor underneath the description field.

    Sorry, my english is very poor. I don’t understand exactly what you mean with curly and straight quotes.

    #45386
    Brendan
    Keymaster

    I would think that you could import a CSV file because Tap Forms allows you to setup a Script Folder that has security permissions to read files from. Then you could use the var csv_data = Utils.getTextFromUrl(url); function to read in the CSV file and then just loop through it parsing out the data and writing it to the database.

    #45385
    Brendan
    Keymaster

    Can you upload a screenshot of your script as you have it?

    Your fieldId is wrong. Also, make sure you’re not using curly quotes for any of the values. They must be straight quotes. The example that Sam posted uses straight quotes, but your code you posted is using curly quotes.

    #45377
    Daniel Leu
    Participant

    There is currently no API available to import CSV files. One way to go around that is to use the clipboard to get data into TF (Utils.copyTextFromClipboard()) or to use external script calls with parameters (see paragraph ‘Calling a script from a URL’ 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

    #45373
    Victor Warner
    Participant

    It appears from another post that it possible to import csv files to a form using Javascript.

    I go lost in the detail (and not being proficient in Javascript) and could not work out how to do so for myself.

    Using a simple database (see attached and csv files) what are the basic format/commands in Javascript to do so?

    Also whether it is possible to import into more than one form at a time.

    In the attached there are two forms (Who and Passport) whether it is possible to import into both of them from the same script.

    INnthe real world version I have data in Filemaker and I am exporting the data record by record and importing through File/Import/Records in Tap Forms. I have automated the steps with Keyboard Maestro – but it is time-consuming and sometimes fails (where Tap Forms or some other processes hangs for a while).

    Any help would be gratefully received.

    Attachments:
    You must be logged in to view attached files.
    #45370
    Fernando DS
    Participant

    This is how the script is redacted:

    function Replace_Metal() {
    var fieldId = ‘fld-fieldid’;
    for (var record of form.getRecords()) {
    var fieldValue = record.getFieldValue(fieldId);
    if (fieldValue.includes(“rock duro”)) {
    record.setFieldValue(fieldId, fieldValue.replace(“rock duro”,
    “heavy metal”));
    }
    }
    form.saveAllChanges();
    }

    Replace_Metal();

    Replace fld-fieldid with a field ID from either the script editor or
    find it in the field editor underneath the description field.

    #45366
    Sam Moffatt
    Participant

    For something like that, a new form script like the following should do it:

    function Replace_Metal() {
      var fieldId = 'fld-fieldid';
      for (var record of form.getRecords()) {
        var fieldValue = record.getFieldValue(fieldId);
        if (fieldValue.includes("rock duro")) {
          record.setFieldValue(fieldId, fieldValue.replace("rock duro", "heavy metal"));
        }
      }
      form.saveAllChanges();
    }
    
    Replace_Metal();

    Replace fld-fieldid with a field ID from either the script editor or find it in the field editor underneath the description field.

    #45360
    Fernando DS
    Participant

    Hi, I would like to have and script to find and modify my records, but i don’t know nothing about programming and it’s very dificult to me to do the script. I use and iPhone and iPad, I have not got a Mac. Could anybody help me? Thank you very much.

    Attachments:
    You must be logged in to view attached files.
Viewing 15 results - 1,141 through 1,155 (of 2,951 total)