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 - 286 through 300 (of 2,989 total)
  • Author
    Search Results
  • #51257
    Daniel Leu
    Participant

    I’m not certain that Brendan’s approach works as expected. The auto-increment number would be independent of the prefix. So you might end with AST001, LLK002, AST003, …. But AST002 would not exist.

    I would use a form script that provides you with the next valid entry. Create a saved search for your prefix’s, and then have a form script analyzes this subset of records and recommends you the next valid number to be used. I do this with barcodes that I assign to my artwork.

    Cheers, Daniel

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

    #51255
    Brendan
    Keymaster

    The trickiest part of your request is to be notified if your sequential number has already been used or not. One way achieve that would be to have a Field script loop through all your records, searching for the value that you just entered and then displaying an alert message.  But it could take a while for 3700 records.

    But the formatting of an index number prefixed with 3 characters would be easily achievable with a Number field with the Auto-increment function enabled and a Calculation field that joins them together using the FORMAT() function.

    For example:

    PREFIX + FORMAT(Number; "000")

    The FORMAT() function will take the Number field and format it so that it contains prefixed 0’s.

     

    Attachments:
    You must be logged in to view attached files.
    #51252
    Brendan
    Keymaster

    Hi Chris,

    There’s no function for accessing the previous record directly. In a Script you could do it, but then you have to fetch the records, then get the record that’s at an index one behind the current record.

    but I have a form and script which you will run on the selected record that can create a new record, copy the data from the original selected record, then switch to the new record.

    Download the attached .tfarc file and import that into your document.

    So what you do is when you have your most recent record selected, run the script called New Mileage Entry (it’ll be on the Scripts tab on the right when you have the Form inspector panel visible). Then type in the new odometer value. Tap Forms will calculate the difference between the previous and new odometer values.

    Hope that helps!

    Brendan

    Attachments:
    You must be logged in to view attached files.
    #51250
    pierrot_rennes
    Participant

    Hi,

    I have 3700 records from a comic book puzzle collection database
    I want to add an index field for classifying boxes according to the collection theme
    examples:
    Asterix = AST
    Lucky Luke = LLK
    etc…
    I would like this field to have a three-digit sequential number and to be notified if it is already used for a theme
    Example: AST001 is already used, I must use AST002
    Is a script possible for this kind of request?
    Thanks in advance

    #51245
    Peter Riley
    Participant

    Thanks Daniel – that works well.  Much appreciated.

    Before this I’ve been fiddling with this script for some time in this and another database document for movies I have watched (it is based on one demonstrated by Sam) but I have had to run it more than once to get the link tables updated, ie the first run gets the json from omdb.com and the console shows that the actors etc are found and suggests they are being added to the link table with this:

    console.log(“Existing actor found – updating link table… ” + candidateRecord);

    record.addRecordToField(candidateField, actors_link_id);

    but the link tables remain blank and I have to run it again to actually populate the table.

    Cheers

    #51238
    Peter Riley
    Participant

    Thanks Brendan,

    Template of the Movies form attached.

    There are also forms for Actors, Directors and Writers.  The way it works is that the IMDB ID is entered into the Movie form, then the script downloads the json from OMDB and populates the form with the movie data.   If an Actor (for example) isn’t found in the Actor table then the name is added to that table, then the Actors, Director and Writers linked tables on the main form are also populated.

    Hope that helps

    P

    Attachments:
    You must be logged in to view attached files.
    #51236
    Brendan
    Keymaster

    Can you please post your script or a template (.tff) that includes the script? Take out any API keys you might have in your code first.

    The scripts do run all in one shot, but the Prompter does interrupt it, but it depends on how the script was written.

    #51233

    In reply to: Add up or down?

    Glen Forister
    Participant

    Thanks for the thought.  That is interesting.

    If I could easily make a duplicate of my TF file and test it, I would try that.  But, I have 79 Forms in my document.  I’ve been burned by tests before.

    It sounds pretty straight forward and if I was just starting out I would try the script, but I have over 200 records now to sort out if things go wrong.

    #51232

    In reply to: Add up or down?

    JScottA
    Participant

    Does this help you? I’ve not tested it but maybe it will spur your creativity for a real solution:

    To achieve the desired effect of consistently placing duplicated records immediately after the original in Tap Forms, a JavaScript-based scripted function could provide a workaround. Here’s a general approach, leveraging the Tap Forms API capabilities found in the documentation:

    1.Retrieve the Current Record’s Position: Identify the position of the original record within the sorted list.

    2.Duplicate the Record: Use the record.duplicate() function to create a copy of the current record .

    3.Insert at Correct Position: Based on the original record’s position in the form’s sorted list, reposition the duplicate if needed. This could be done by iterating over records to ensure the duplicate’s position is adjusted relative to the original.

    Here’s a basic script outline:

    // Retrieve the current record

    var records = form.getRecords();

    var currentRecord = form.getSelectedRecord(); // assuming this is the record to duplicate

    var index = records.indexOf(currentRecord);

    // Duplicate the record

    var duplicatedRecord = currentRecord.duplicate();

    // Reposition the record if needed by sorting again or programmatically moving

    // Example: You might delete and re-add in sorted order if Tap Forms sorting is strict

    form.saveAllChanges();

    This script, while a creative workaround, may have limitations if Tap Forms enforces strict sorting on save, potentially reordering records automatically. Testing would determine if the manual duplication places the record in the intended position consistently.

    #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, 3 months 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

Viewing 15 results - 286 through 300 (of 2,989 total)