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 - 106 through 120 (of 2,864 total)
  • Author
    Search Results
  • #51701
    Josef Senti
    Participant

    Is there a way to run a file from a path in a field using script?

    I try to make a movie database. In a table I have a field with the path to the MP4 or ISO file.
    Is there a way to write a script that can make that file run with VLC Player when I press a shortcut or a button or whatever is possible?

    #51693
    Stuart Barry
    Participant

    I already had the save command and console log. The type-id field is picked up correctly by the colour only changes when I run the script manually. I’d like it to run automatically on changing the colour field using the drop down box. Script shown below.

    function Change_record_colour() {

    var type_id = record.getFieldValue (‘fld-631813d9eff54787894020691031bc77’);
    var red_col = “#ffbac6”;
    var white_col = “#caffd4”;
    var sweet_col = “#fef3a4”;
    var fort_col = “#fdbb9c”;
    var spark_col = “#a3ff79”;
    var rose_col = “#f4d8dd”;

    console.log(type_id);

    if (type_id == “Red”)
    {record.setRecordColor(red_col);}

    if (type_id == “White”)
    {record.setRecordColor(white_col);}

    if (type_id == “Sparkling”)
    {record.setRecordColor(spark_col);}

    if (type_id == “Sweet”)
    {record.setRecordColor(sweet_col);}

    if (type_id == “Fortified”)
    {record.setRecordColor(fort_col);}

    if (type_id == “Rosé”)
    {record.setRecordColor(rose_col);}

    form.saveAllChanges();

    }

    Change_record_colour();

    #51672
    Daniel Leu
    Participant

    I don’t know how long your objective description is, but maybe you can use markdown to format it.

    Here’s a field script that fetches all the activities records and formats them as markdown.

    You need to update field ids for the activity form and the respective fields. Additionally, define a summary field in your main form of type markdown.

    When you update an activity record, the summary field is updated. The first line is the number and title, followed by the objective. Unfortunately, TapForm 5’s markdown implementation doesn’t support tables.

    Hope this helps! Bonne chance!

    function Update_Summary() {
    
    	// define the field ids
    	const activities_id = 'fld-xxx';
    	const activities__number_id = 'fld-xxx';
    	const activities__title_id = 'fld-xxx';
    	const activities__objective_id = 'fld-xxx';
    	const summary_id = 'fld-xxx';
    
    	// get activities records
    	let activities = record.getFieldValue(activities_id);
    	
    	let md = "# Activities\n\n";
    		
    	// loop over all activities and create the markdown entries
    	for (activity of activities){
    		let number = activity.getFieldValue(activities__number_id);
    		let title = activity.getFieldValue(activities__title_id);
    		let objective = activity.getFieldValue(activities__objective_id);
    		
    		md += `**${number}: ${title}**   
    ${objective}    
    `;
    	}
    		
    	// update markdown field
    	record.setFieldValue(summary_id, md);
    	document.saveAllChanges();
    }
    
    Update_Summary();

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

    #51662
    Brendan
    Keymaster

    Hi Sybille,

    On your custom layout, you can adjust the widths of the columns on your Link to Form field to make the related table look a bit nicer. You may also want to print in landscape orientation so you can get more space on the page for your columns.

    What does it currently look like? Can you post a screenshot?

    Thanks,

    Brendan

    P.S. I’m moving this topic out of the Scripting Talk forum because it doesn’t have anything to do with scripting as far as I can tell.

    #51660
    Sybille van Zuylen
    Participant

    Hello,
    I’m using tap forms to prepare coaching sessions.
    I have a “session” table which is related to “activity” table.
    Each session has several activities which are numbered in the order I want to do them.
    From there, I am trying to prepare a “session summary” printout to give to the client where all activities and their descriptions are listed in the correct order.
    So I made a new presentation (I’m sorry if the word is not right, I’m using the French translation).

    My problem is I manage to display the “activity” table within the page, but its content is of course cropped in a way that makes it unusable.
    How can I make a well designed text list of the activities related to my “session” record?

    • This topic was modified 4 months ago by Brendan.
    #51654

    In reply to: calendar feature

    Daniel Leu
    Participant

    There are a few issues with the ChatGPT proposal: one is that TapForms 5 doesn’t support calling AppleScripts. Utilities.executeAppleScript(script); is not supported. The API is documented in https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api.

    TapForms has an API to support adding events to the calendar: Utils.addToCalendar() and Utils.updateCalendarEvent(). So maybe the proposed code can be adapted to use these functions.

    I don’t use the calendar integration with TapForms so I don’t know the details how it works. There’s an example in the API documentation.

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

    #51653

    In reply to: calendar feature

    JScottA
    Participant

    Using the custom GPT, Tap Forms 5 Assistant (unofficial), I got the following. Maybe it can assist you:

    Response to Tech Support Post

    1. Automating “Add to Calendar” for New Entries

    Currently, Tap Forms requires users to manually press the “Add to Calendar” button for each entry in a date field. There is no built-in setting to automate this process for new records.

    However, automation might be possible using scripting. Tap Forms supports JavaScript for automating tasks, and it may be possible to write a script that triggers the “Add to Calendar” function whenever a new record is created. You can refer to Tap Forms Scripting 101 for guidance on scripting in Tap Forms.

    To apply this automation to existing records, a script could loop through all records and execute the “Add to Calendar” function in bulk.

    2. Toolbar Calendar Icon Not Jumping to Current Month

    From the Tap Forms manual (Section 7.3, Calendar View, p. 47-48), the calendar view allows navigation between months, but clicking on the calendar icon in the toolbar does not automatically jump to the month displayed in list mode. You must manually navigate the calendar using the arrows at the top.

    3. Calendar Not Jumping to Selected Record in Sidebar

    In the Calendar View, selecting a record from the list in the sidebar does not cause the main calendar view to jump to the corresponding month of that record. This behavior is currently by design.

    A potential workaround could be:
    • Clicking on a specific date within the calendar to filter records displayed.
    • Using a Saved Search to focus on specific date ranges.

    Summary & Suggested Fixes
    • Automate “Add to Calendar”: Use JavaScript scripting.
    • Toolbar Calendar Icon Behavior: No automatic jump to the current month.
    • Calendar Sidebar Selection: Selecting a record in the sidebar doesn’t change the calendar view.

    Would you like help drafting a script to automate adding records to your Apple Calendar?

    and…

    Here’s a Tap Forms JavaScript script that will automatically add records to your Apple Calendar when a new record is created. This script iterates through all records in a form and adds any missing entries to the Apple Calendar.

    Steps to Use the Script:
    1. Open Tap Forms.
    2. Navigate to the Form where you want to automate the “Add to Calendar” function.
    3. Open the Scripts Editor.
    4. Create a new Script Field and paste the script below.
    5. Run the script manually or set it up to execute automatically when new records are added.

    Tap Forms Script to Add Entries to Apple Calendar

    // Tap Forms script to automatically add all records with a date field to Apple Calendar

    function addToCalendar() {
        var form = document.getForm(); // Get the current form
        var records = form.getRecords(); // Get all records
        var dateField = form.getFieldNamed("Your Date Field Name"); // Change to match your Date field name
        var titleField = form.getFieldNamed("Event Title"); // Change to match your title field
        var calendarScriptField = form.getFieldNamed("Added to Calendar"); // Optional: Track if event was added
    
        if (!dateField || !titleField) {
            alert("Please check that you have a valid Date and Title field.");
            return;
        }
    
        for (var i = 0; i < records.length; i++) {
            var record = records;
            var eventDate = record.getFieldValue(dateField);
            var eventTitle = record.getFieldValue(titleField);
            var addedToCalendar = record.getFieldValue(calendarScriptField); // Check if already added
    
            if (eventDate && eventTitle && !addedToCalendar) {
                var script = 

    tell application “Calendar”
    set newEvent to make new event at end of calendar “Your Calendar Name”
    set start date of newEvent to date “${eventDate}”
    set summary of newEvent to “${eventTitle}”
    end tell
    `;

    // Execute AppleScript to add event to Calendar
    var result = Utilities.executeAppleScript(script);

    if (calendarScriptField) {
    record.setFieldValue(calendarScriptField, “Added”);
    }

    console.log(“Added to Calendar:”, eventTitle, “on”, eventDate);
    }
    }
    }

    // Run the function
    addToCalendar();

    `

    How It Works
    • This script retrieves all records in a form.
    • It checks for a date field and an event title field.
    • If a record hasn’t already been added to the Apple Calendar, it:
    • Runs an AppleScript command to create an event in Apple Calendar.
    • Marks the record as “Added” (if you have a field for tracking).

    Setup Instructions
    1. Replace “Your Date Field Name” with the actual Date field name in your form.
    2. Replace “Event Title” with the name of your event Title field.
    3. Replace “Your Calendar Name” with the actual name of your calendar in Apple Calendar.
    4. Optional: Create a new Text field named “Added to Calendar” in your form to track which records have already been added.

    Execution & Automation
    • Run this script manually to add existing records.
    • If you want it to auto-run when a record is created, use a Trigger Script Field with Tap Forms.

    Would you like assistance setting up an automatic trigger for new records? 🚀

    If you want further assistance, you can use the assistant or wait for the Safe of TF to give you to canonical response.

    #51627

    It would be ideal to be able to attach a file in a file attachment field and be able to add a description and a date on it. I suppose one can name the file before attaching it, but it would be way better to be able to do it in the form.

    #51626
    Brendan
    Keymaster

    So you’re changing the value of your fld-631813d9eff54787894020691031bc77 field? That should trigger the script to run. Put in a console log to see if that solves the problem. Also don’t forget to call form.saveAllChanges() to commit the change to the database. That generally triggers a refresh of the display.

    #51614
    Daniel Leu
    Participant

    You could import your CSV data into a separate form using TapForms import function. Then you link the two forms together using the join relationship with the student identifier fields set to match values.

    Now you can get all the information from the import in your main form. You could use a field script to extract some information to make it more legible.

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

    #51612
    Courtney Craig
    Participant

    Hey all,

    I am by no means a coder, but I love Tap Forms and use it in the business I work for. I have a dilemma that I am hoping someone might be able to help with.

    Context – we take school photos and have parents complete an authorisation form at the beginning of every year for what their student can order throughout the year.

    I’m hoping to write a script that will take the CSV data I receive from the parents and merge it with the school provided student data, based on a unique identifier like a student number. Has anyone done something similar and be able to help?

    The CSV contains a fair amount of data, parents can select what they want their son to order for several different photos, along with credit card information and shipping information.

    Thanks,
    Courtney

    #51603
    Stuart Barry
    Participant

    I have created a script that works to change the colour of the record conditionally. I initially created it as a form script and can run it or use a shortcut and it does what it is supposed to do. I tried the same script on a field because I want it to activate automatically as soon as a new record is added or an existing one changed. Although the script works when I run it manually on the field it does not automatically activate when the reference field is modified.

    The first line of code (var type_id = record.getFieldValue (‘fld-631813d9eff54787894020691031bc77’);) references the field and gets the data successfully.

    Any suggestions?

    #51592
    Daniel Leu
    Participant

    But is there a way to set the scripts to run automatically for each post?

    Yes, you must use a field script instead of a form script. Create a new field of type script and assign the code you already have. This is why I recommended to use the return value instead of setting another field’s value. This makes it easier to understand what’s going on, specially if you have several scripts.

    • This reply was modified 5 months ago by Daniel Leu.
    • This reply was modified 5 months ago by Daniel Leu.

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

    #51589
    Josef Tingbratt
    Participant

    Thanks i did solve it oth help from ChatGPT, I just needed to point out the correct table to search in :)

    But is there a way to set the scripts to run automatically for each post?

    #51584
    Daniel Leu
    Participant

    It seems that the script is a bit more complicated than it needs to be. You only have one customer per note, don’t you? The script assumes several. I would remove the save field functionality and just use the return value. Set the return type to text.

    Just out of curiosity, I used ChatGPT to simplify your script and the result seems reasonable:

    function calc() {
        // Fält-ID för det fält i relaterade tabellen som innehåller namn
        var namn_id = 'fld-e59a27d956a442f7b1995c71bffdde1e';
    
        // Fält-ID för fältet som länkar till relaterade poster
        var relaterade_falt_id = 'fld-1234567890abcdef1234567890abcdef';
    
        // Hämta relaterade poster
        var relateradePoster = record.getFieldValue(relaterade_falt_id);
    
        // Kontrollera om det finns exakt en relaterad post
        if (relateradePoster && relateradePoster.length > 0) {
            // Hämta namn från den relaterade posten
            var namn = relateradePoster[0].getFieldValue(namn_id);
    
            // Returnera namnet
            return namn;
        } else {
            // Om inga relaterade poster finns, returnera en tom sträng
            return '';
        }
    }
    

    I think you could achieve the same result by using a calculation field. Select the field of your related form and set the return value to text.

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

Viewing 15 results - 106 through 120 (of 2,864 total)