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,246 through 1,260 (of 3,052 total)
  • Author
    Search Results
  • #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.
    #45331
    Brendan
    Keymaster

    Hi Tom,

    The act of choosing a folder from the user interface is what gives Tap Forms permission to access files within that folder.

    Tap Forms can have a different Script Folder for each document. Could it be that you were working with multiple documents and it just seemed like you had set it before but because it was a different document it hadn’t been set yet?

    #45328
    Tom Kerswill
    Participant

    Hi

    Quite often when writing a new script and pointing to a new file, I get undefined when doing getJsonFromUrl() or getTextFromUrl()

    I’m pretty certain this is due to permissions errors. Is there any way of catching an error in Tapforms script and seeing what the error is from a call like this? At the moment it’s impossible to distinguish between permissions errors or something else.

    What I’ve found in the past is that I’ve had to go into Tapforms preferences, and choose a comletely different folder for script folder access, and then set my chosen one again. But this always seems a bit flakey; sometimes when I go back into preferences the folder apparently hasn’t changed.

    I’m also not certain it works if you set a higher-up folder. E.g. ideally I’d like to set my “Documents” folder, but this doesn’t seem to always allow access to files in subfolders.

    Is there perhaps a different way to set permissions? Or perhaps Tapforms could ask for permissions when something tries to access a folder for the first time, using the Security preferences etc.

    Thanks in advance,

    Tom

    #45324
    T.L. Ford
    Participant

    I’m glad the scripting tutorials are useful. Eventually, I really need to get around to 103. :)

    #45318
    Stephen
    Participant

    Hi,

    I’ve created a field script to colour a record green when the task is complete. All looks great in the desktop version, clearly brightly filled rows in the linked table display of records.
    In iOS the view is slightly underwhelming & easily missed that tasks are complete, just a subtle coloured line at the top of the record once you tap to enter the linked form, no clear indication whilst viewing the table list of records.

    Is there anyway of making this colour change more obvious to mobile users at a glance?

    Thanks in advance for any suggestions, Stephen.

Viewing 15 results - 1,246 through 1,260 (of 3,052 total)