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 - 256 through 270 (of 2,950 total)
  • Author
    Search Results
  • #51231
    Peter Riley
    Participant

    Hi,

    My movie media database takes the value of the IMDB id field (eg tt0433442) and does a lookup via the omdb API to retrieve that movie’s data – actors, director etc – and populate the record.  That works fine but some of my older records are missing the id, in which case the lookup fails of course.

    So I’ve added some code to my script that checks whether the id field is blank and if so calls a function that uses the standard Prompter script template and that asks for the id and populates the id field so the rest of the code won’t fail.

    The prompt and setting of the id field value works OK, but I see from the console that the rest of the script is still running (and failing) even before I’ve input the id into the Prompter dialogue box and clicked ‘Go for it!’.  Is that by design or am I missing something?

    Thanks

    #51215
    Brendan
    Keymaster

    Hi Chris,

    There are a few features that are Mac only and a few that are iOS only.

    You can definitely write scripts and Calculation field formulas in the iOS version.

    The following features are in the Mac version only:

    • Custom layouts
    • Advanced printing
    • Labels engine
    • Barcode generation
    • Calendar View
    • Map View
    • Charts View

    The iOS version has these features that the Mac version does not:

    • Barcode scanning
    • Audio recording
    • Drawing

    Other than those differences, both versions have the same features. They just operate differently due to platform differences.

    #51213
    Chris Templeton
    Participant

    I’d like to get this app for the iphone. Since this is mainly targeted to Mac users, what limitations will I run into just using it on an iphone/ipad. Like will I be able to do any scripting / formulas?

    #51202
    Daniel Leu
    Participant

    Hi Stephan,

    Yes, it’s always a good idea to make a copy of a document to try new things.

    I have updated and enhanced the script to work on the current search. Although ChatGPT claims that’s not possible, but it is :).

    Initially I didn’t use ‘, ‘ as a separator because I wasn’t certain that your input data is consistently using it. It now uses a comma when parsing the input, then removes all leading and trailing spaces, and finally uses ‘, ‘ when creating the output string. This makes it easier to read.

    Using a selector, you now define the operation of the script, either ‘add tag’ or ‘remove tag’.

    The script is getting a bit too long for the forum here. You can find it on my blog at https://lab.danielleu.com/blog/working-with-tags/.

    • This reply was modified 1 year ago by Daniel Leu.

    Cheers, Daniel

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

    #51201
    JScottA
    Participant

    Perhaps this will help?

     

    Here’s how you can address the issues presented:

    1. Adding Spaces Between Tags

    To add a space between tags when concatenating them in a script, you can modify your script to concatenate tags with a comma and a space (“, “). You can do this by updating the part of your script where the tags are combined. For example, if you are using the CONCAT function, you can write:

    var tags = tag1 + “, ” + tag2 + “, ” + tag3;

    This will format your tags with a space after the commas, displaying them as Tag1, Tag2, Tag3.

    Alternatively, you can loop through a collection of tags and concatenate them dynamically with spaces like this:

    var tags = tagsArray.join(“, “);

    This will join all elements of the array tagsArray with “, ” between them.

    2. Performing Actions on the Currently Displayed Saved Search

    Unfortunately, there is no direct way to get the currently selected saved search in Tap Forms using a script. However, you can manually specify which saved search to run the script on by defining it in your script. For example, you can use:

    var selectedSearch = “My Saved Search”;

    If you wish to make your script more flexible and allow the user to input or choose the search when running the script, you would need to set that up manually, as Tap Forms doesn’t currently offer a script-based selection of saved searches dynamically.

    To streamline the workflow, I recommend testing your script on a sample or test database, as you mentioned, to avoid unintentional changes.

    For more details, refer to page 53 for information on scripting and handling such cases within Tap Forms .

    Let me know if you need further clarification!

    You can check out the Tap Forms Scripting 101 guide here.

    Try the Tap Forms 5 Assistant GPT here: https://chatgpt.com/g/g-aGOEAlajR-tap-forms-5-assistant

    #51199
    Anonymous
    Inactive

    Thaks a alot! This acutally works. Danke!

    But something unexpected happened. I didn’t expect that it acutally adds the tags when clicking the play-button in the “Edit script” window, so now I have “Test” in every of those records. :/ I thougt it would check the script for errors but not actually perform it live. Any idea how to remove them again?

    I should set up a test database for testing.

    Questions:

    1. New tags are added without a space, which means the result is like: Tag1,Tag2,Tag3. How can I add a space in the script? For readability reasons I want to display it like this: Tag1, Tag2, Tag3  (I know that I will forget to add a space manually when entering new tags.)

    2. It performs the changes on the hardcoded saved search “Selcted”. Is it possible to “get” the currently displayed saved search? Or to enter/select, on which saved search it should be performed? (Not citical but it would streamline the workflow.)

    -Stephan

    #51198
    Daniel Leu
    Participant

    Do you have some type of criteria to select these records? Can you create a saved search for them? Or is it for all records?

    Do add them to the list, I think the only way is using a script. Here’s an example of what I’m using:

    var prompterVar;
    
    function callbackSetTag() {
       const name_id = 'fld-xxx';
       const tags_id = 'fld-xxx';
       // get records from a saved search
       let recs = form.getSearchNamed('Selected').getRecords();
       // // use all records
       // let myRecords = form.getRecords();
       console.log('Found ' + recs.length + ' records');
       for (rec of recs){
          console.log("Processing " + rec.getFieldValue(name_id))
          var tags = new Array();
          // load initial values
          var tag = rec.getFieldValue(tags_id);
          // create an array of tags
          if (tag) {
             tags = tag.split(",");
          }
          // add new tag
          if (prompterVar){
             tags.push(prompterVar);
          }
          // save new tags
          rec.setFieldValue(tags_id, tags.toString());
          console.log("Setting tags: " + tags.toString());
       }
       document.saveAllChanges();
    };
    function setTag(){
       let prompter = Prompter.new();
       prompter.addParameter('Tag', 'prompterVar', 'text')
       .show('Add Tag to current record', callbackSetTag);
    }
    setTag();
    You will need to update the name_id and tag_id constants. name_id is used in the console log to provide some infos on which record the routine is running. tag_id is the field where you collect your tags. In your case, that would be the Mailings field.
    Next, you have to decide if this works on a saved search or on all records. My saved search is called Selected. Either you update this, or comment this line and uncomment the next block to perform the tagging on all fields.
    When you run the script, you get a prompter where you enter the new tag. Note, the tag may not contain commas!
    Hoffentlich hilft das. Viel Spass und Erfolg!

    Cheers, Daniel

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

    #51196
    Anonymous
    Inactive

    Hi,

    is there a way to add text to a text field of multiple records? In My example I am sending out mailings and want to note that in those records which will get the mailing.

    The field is set up as a text field and has the selection thing, where I can choose from the list.  The first two mailings I just filld the field by dragging the yellow dot in a spreadsheet-style.

    Ticking off over one thousand records individually is quite time consuming.

    I thought I could select those records and then select from the list to add it. But that’s not possible.

    My attempt to do a script failed miserably, my brain seems to work the other way around.

    Any Ideas how this could be done? Or has anyone already done a script fot this kind of operation?

    Thanks

    Stephan

     

     

    #51194
    Daniel Leu
    Participant

    You can do this with a field script that formats your field whenever you change it. You need to update the text_id variable to point to your text field. I would recommend to hide the field script in order not to clutter the default view.

    
    function capitalizeFirstLetter(string) {
    
        return string.charAt(0).toUpperCase() + string.slice(1);
    }
    function Text_Formatter() {
       var text_id = 'fld-b6f734989f3742c8b6d1ad301eefea32';
       let text = record.getFieldValue(text_id);
       text = capitalizeFirstLetter(text.toLowerCase());
       record.setFieldValue(text_id, text, false);
       document.saveAllChanges();
       return text;
    }
    Text_Formatter();

    I noticed that the script wasn’t triggered when I first created it. Closing and reopening the TapForms document fixed it!

     

     

    Cheers, Daniel

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

    #51181
    John Hamill
    Participant

    Hello,

    I cannot see a method for achieving the enclosed (screenshot) search which necessitates a combination of ‘AND’ and ‘OR’ logic, a compound logic statement. [The second screenshot is included for information only and displays the ‘Rating’ field that I wish to add].

    I can go to Javascript. But when using Javascript, is it possible to replicate a “saved search” with all of its functionality (browsing through records etc) without major coding ie. creating a new table and populating that new table with the search results?

    Or perhaps, I am missing something simple?

    Thanks for any assistance.

    • This topic was modified 1 year, 1 month ago by John Hamill. Reason: Original did not attach images
    Attachments:
    You must be logged in to view attached files.
    #51156
    JScottA
    Participant

    Maybe this response from the ChatGPT Tap Forms 5 Assistant can help you. It is a bit long, but that is how this custom GPT works. I hope it helps:

    It seems the user is facing an issue with JavaScript’s .match() method and handling null values. Here’s what I can suggest based on their code.

    ### Issues with the Provided Script:
    1. **Incorrect Regex Format**: The regular expression is defined as a string ("/5bq/"). In JavaScript, regular expressions should not be placed inside quotes like that unless explicitly instantiated using the RegExp constructor. Alternatively, regular expressions can be directly written using the / delimiter without the need for quotes.

    2. **Null Handling**: The user is correct that .match() returns an array when a match is found and null when no match is found. The current handling of null is fine with the if (found === null) check, but fixing the regex issue should resolve their problem.

    ### Suggested Fix:
    Here’s a corrected version of their script:

    `javascript
    function Test_Script() {
    const regex = /5bq/; // Corrected regex format
    var tstr = “ytube5bq891”;
    const found = tstr.match(regex);

    if (found === null) {
    console.log(‘No match’);
    } else {
    console.log(‘Match found’);
    }
    }

    Test_Script();
    `

    ### Explanation:
    – **Regex without quotes**: The regular expression /5bq/ is now correctly formatted as a regex object, not a string. JavaScript will treat this as a valid regex pattern and search accordingly.
    – **Null Check**: The rest of the code remains the same because the handling of null and matches with if (found === null) is already correct.

    ### Additional Notes:
    – If you want to dynamically create a regex (e.g., from user input), you would use the RegExp constructor like this:
    `javascript
    const regex = new RegExp(‘5bq’);
    `

    This should fix the issue and allow the script to properly check for matches.

    For further Tap Forms scripting assistance, you can refer to [Tap Forms Scripting 101](https://www.cattail.nu/tap_forms/tap_forms_scripting_101/index.html). You can also check the scripting section in the Tap Forms documentation around page 53 [oai_citation:1,1328_16794_en_1538683502.pdf](file-service://file-15C3MsaZPdU2JvfF2hiej31w).

    You can check more about Tap Forms here: [Tap Forms Assistant](https://chatgpt.com/g/g-aGOEAlajR-tap-forms-5-assistant).

    #51155
    John Hamill
    Participant

    Hello Daniel,

    I was a bit presumptuous above. I am still having a problem with your script. I have simplified the problem – it may be down to the Javascript ‘match’ function returning an array (true), otherwise returning null, null having its own “difficulties” in Javascript. I have excluded the field id for the present to simplify it. I am still unable to get it working however. Here is my test script:

    function Test_Script() {
    const regex = “/5bq/”;
    var tstr = “ytube5bq891”;
    const found = tstr.match(regex);
    if (found === null)
    console.log(‘No match’);
    else
    console.log(‘Match found’);
    }
    Test_Script();
    #51146
    Daniel Leu
    Participant

    If I run into issues with the search, I tend to write a field script:

    
    
    function Match_T259S() {
    var field_id = 'fld-xxxx';
    var field = record.getFieldValue(field_id);
    const regex = /\&t=259s/g;
    const found = field.match(regex);
    return found ? 1: 0;
    }
    Match_T259S();
    Then I create a saved search on that field. You need to adjust the field_id for the field that contains your URL text. The return value of this field script is integer.

    Cheers, Daniel

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

    #51131

    In reply to: Movie Library Template

    Anonymous
    Inactive

    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.

    Is the update faulty? I just downloaded it.

    #51101
    Kyla Lemon
    Participant

    Hi All –  I am running a Quilt Show using Tap Forms!  I have done so much already (actually very easy to use), but I need to figure out one more thing.  I have 200 records, one record per quilt entry.  I have already made layouts for display cards, layout cards, and spreadsheets for other committees.  But I need to group/link records by “quilter”.  I need a layout that will list all of the quilts entered by one individual.  We use this layout to check-in and check-out quilts.  Some people enter 1 quilt, others have 5 or more.  Not sure if this requires a script or linking records?  Any advice would help, as I am running out of time, the show starts on 9/19.  Thank you! – Kyla

Viewing 15 results - 256 through 270 (of 2,950 total)