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 - 226 through 240 (of 2,950 total)
  • Author
    Search Results
  • Jo M
    Participant

    Wow !

    Well, first of all, thank you so so so much for your answers guys ! I appreciate so much and it helps me to improve myself as much as I can but it’s not that easy when you’re a beginner all alone

    In fact, I want to do this kind of things with many fields such as links for Whatsapp, Telegram, Instagram and so on in order to create a big adress book of my contacts.

    The script you created seemed to contain an error (or I don’t know but I had an error message) that I could solve thanks to chatGPT (I wasn’t able to do it alone) :

    The issue is in the following line:

    javascript
    const phone_number = var phone_number_id = ‘fld-XXX’;
    In this line, you declare a constant (const phone_number) and try to initialize it with another declaration (var phone_number_id). This is not valid in JavaScript because a declaration cannot be used as an initialization value.

    Fix
    You need to separate the declarations and initializations properly. Here’s a corrected version of the script:

    Changes Made
    Separated Declarations:

    Removed const phone_number = var phone_number_id = … and declared phone_number_id and whatsapp_id_id separately.
    Correct Identifier Usage:

    Used phone_number_id and whatsapp_id_id in the appropriate places.

    I tried another one by myself, can you tell me what you think (take a look at the type of the field because it’s not a number phone here) ? It seems to work perfectly :

    function Nouveau_Script() {
        // Replace with your own code
        var hello_world = "Bonjour tout le monde !"; 
        return hello_world;
    }
    
    Nouveau_Script();
    
    function Script() {
        // Define used fields
        const id_id = 'fld-XXX';
        const lien_id_id = 'fld-XXX';
    
        // Define Twitter API
        const lien = "https://twitter.com/i/user/";
    
        // Get the ID from the record (assuming this method exists)
        let id = record.getFieldValue(id_id);
    
        // Define call URL
        let url = lien + id;
    
        // Set URL
        record.setFieldValue(lien_id_id, url);
    
        // Save changes
        document.saveAllChanges();
    
        // Output result to console
        console.log(url);
    }
    
    Script();

    – Is there a way to add the ID directly to the link or have I to create a 3rd field in which there will be [Link] + [ID] ? Or at least I’ll hide the useless field with the default value.
    – If I use the method of Brendan : will it create a complete link in the tapforms app (I mean will it combine the two fields in the link field and show the complete link or will it combine only if I click on the globe button in order to access to the website) ?

    Sorry in advance for my English mistakes.

    Best regards,
    Jo M

    (sorry for the duplication but I edited my message and it doesn’t appear so I post it again)

    Daniel Leu
    Participant

    Hi Jo,

    You can use the concat function or just + in the calculation field to combine two fields. But this wouldn’t create a valid URL since the phone number uses the format +1 (123) 456-7890.

    Here’s a field script that takes the phone number as input and sets the URL field as the result. Then you can click on the url globe and the Whatsapp API is called using your default browser.

    The whatsapp field is of type Web Site, and phone number is of type Phone Number. You have to update the id for these two fields. You can find their values in the script editor on the left side.

    function Script() {
    
    	// define used fields
    	const phone_number_id = 'fld-xxx';
    	const whatsapp_id = 'fld-xxx';
    
    	// define whatsapp API
    	const whatsappUrl = "https://api.whatsapp.com/send?phone=";
    	
    	// get phone number and format it to work with the API
    	let phone_number = record.getFieldValue(phone_number_id).replace(/[ ()-]/g,"").replace("+","00");
    	
    	// define call URL
    	let url = whatsappUrl + phone_number;
    	
    	// set URL
    	record.setFieldValue(whatsapp_id, url);
    	
    	// save changes
    	document.saveAllChanges();
    	
    	// output result to console
    	console.log(url);
    }
    
    Script();
    

    Cheers
    /daniel

    • This reply was modified 10 months, 1 week ago by Daniel Leu.

    Cheers, Daniel

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

    Jo M
    Participant

    Hi the community !

    I am a new user of tapforms since a few months but I want to develop my skills in automation and so on.

    Is there a way to create a script that combines 2 records and that automatically fill a field ?

    I explain myself :

    Field 1 : number phone field entered manually
    Field 2 : link field : https://api.whatsapp.com/send?phone= > this field never changes it’s a default value
    Field 3 : I want to automatically combine field 2 + field 1

    I tried with chatGPT, it gave me something that seemed to work but it doesn’t.

    So, my question is : is it possible to do so and is it possible for one of you to help me with this kind of script ?

    Thank you so much for your answer and sorry for my english if I did mistakes I am french ahaha

    Best regards,
    Jo M

    #51407

    In reply to: Previous Record Script

    Daniel Leu
    Participant

    Hi Glen,

    Set the return type of your Today & Previous script to number! As text, it concatenates the fields instead of adding them.

    Here’s the yesterday’s hours script:

    function yesterdays_hours() {
    	
    	var records = form.getRecords();
        	var currentRecordIndex = records.indexOf(record);
    
        	if (currentRecordIndex > 0) {
            	var previousRecord = records[currentRecordIndex-1];
        	} else {
         		return 0;
        	}
    	
    	var today_hours_id = 'fld-7ecb8ad8fe3a4b6db80ea939a60accb2';
    	var yesterday = previousRecord.getFieldValue(today_hours_id);
    	
    	console.log("Yesterday: " + yesterday)
    
    	return yesterday;
    }
    
    yesterdays_hours();

    Cheers, Daniel

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

    #51405
    Glen Forister
    Participant

    I used this before with rain and it works in that Form. I copied the working script for rain and used it here.
    I changed the fld- numbers to be for this form.
    The calculations seem to be doing something unexpected.
    Please tell me what is wrong?

    If you get this to work, another question is how do I get the total sum from one record displayed in the next record?
    In each record I want to show
    Today’s hours
    Yesterday’s total hours
    Today Total hours (which is the sum of the above.

    I like to see these so I know the math is working and I can easily check.

    Attachments:
    You must be logged in to view attached files.
    #51404

    In reply to: Tables

    Brendan
    Keymaster

    There’s no function to get the “previous record” in order to get a total. The previous record can change depending on what your sort ordering is.

    But you can click the little Sigma ∑ button to show the calculation row so you can see the grand totals for the values in a Table field. What do you mean where can you put it so you can see it? It’s at the bottom of the Table field.

    Do you mean you want the total for that column to appear in the parent form somewhere in a separate field? If so, you can add a Calculation field or Script field to compute that value and display it in the parent record.

    The fields that are available to you are mostly the same as the fields that are available to you in a regular form. But only the more simple field types and not the complex ones like Link to Form, Table, File Attachment, etc.

    #51397
    JScottA
    Participant

    The following is a response from the Tap Forms 5 Assistant (an unofficial custom GPT for Tap Forms). Remember that Brendan is the say on anything Tap Forms related. Also, confirm with the manual for Tap Forms:

    To update tasks with the Project Name automatically when creating them in Tap Forms, you can enhance your script to dynamically fetch and assign the project name from the parent record to the linked tasks.

    Solution:

    The current limitation with Advanced Find and Replace for linked fields can be bypassed by modifying the script to propagate the Project Name value programmatically. Here’s how you can refine your script:

    Adjusted Code Example

    Replace the hard-coded “PUMXXX” value with a dynamic retrieval mechanism from the parent project record. For instance:

    function Ais_Pum_Default_Tasks() {
        // Field IDs
        var title_id = 'fld-a34e5fd309dc4a9385d4b44736547f96';
        var priority_id = 'fld-cf942f13d8f14338966a81ccdd30ad81';
        var category_id = 'fld-fe9f869cf75a484ab4e3ca70f4c3dc43';
        var environment_id = 'fld-4a3951d0ef7b4e24a7affbf0afdbe6e3';
        var project_name_id = 'fld-e63dc1cd09cc4448b5d9e92005cb2dcf';
        var status_id = 'fld-77ad662cdb234741a5aff92434f600ac';
    
        // Get the current record (assumed to be the parent Project record)
        var parentRecord = document.getFormNamed('Project').getSelectedRecord();
        if (!parentRecord) {
            console.log("No project record is selected.");
            return;
        }
    
        // Retrieve the Project Name from the parent record
        var projectName = parentRecord.getFieldValue(project_name_id);
    
        // Check if Project Name exists
        if (!projectName) {
            console.log("Project Name is not set for the selected project.");
            return;
        }
    
        // Define tasks and their attributes
        var tasks = [
            { title: "PUM Server Selection", priority: "High", category: "PUM", environment: "N/A", status: "NotStarted" },
            { title: "Install and Configure PUM", priority: "High", category: "PUM", environment: "N/A", status: "NotStarted" },
            // Add other tasks here...
        ];
    
        // Create and populate each task record
        tasks.forEach(function (task) {
            var taskRecord = form.addNewRecord();
            taskRecord.setFieldValues({
                [title_id]: task.title,
                [priority_id]: task.priority,
                [category_id]: task.category,
                [environment_id]: task.environment,
                [project_name_id]: projectName, // Assigning dynamic Project Name
                [status_id]: task.status
            });
        });
    
        // Save changes
        document.saveAllChanges();
        console.log("Tasks generated and linked with project: " + projectName);
    }
    
    Ais_Pum_Default_Tasks();

    Explanation:
    1. Retrieve Parent Record: The script fetches the current project record using getSelectedRecord() from the Project form.
    2. Dynamic Assignment: The Project Name is read from the parentRecord and assigned to each new task in the child Tasks form.
    3. Save Changes: After updating the tasks, document.saveAllChanges() ensures that changes are persisted.

    Benefits:
    • Efficiency: Eliminates the need for manual updates or Advanced Find and Replace.
    • Dynamic Linking: Automatically associates tasks with the correct project name.

    Testing:
    • Make sure you have the appropriate permissions and field IDs set correctly.
    • Select a project record in the parent form before running the script to ensure proper linkage.

    #51364
    ictapforms
    Participant

    Thank you for your thoughts. As mentioned in my original post, I’m aware of the menu-based option. I’m trying to AVOID going into the menu because that both takes longer and is (for me at least) more prone to error than a single button with confirmation (as on the MacOS version of Tap Forms).

    The “swipe left to delete” option on the main form would be difficult to implement on the child form given the way the child form works, but is there some other way of accomplishing what I want? I’d be content even with a script with an associated button on a custom Layout – if that’s even possible.

    • This reply was modified 11 months ago by ictapforms.
    #51359
    pierrot_rennes
    Participant

    Hi,

    I’m glad to hear that a new version is coming soon
    I want to mass change the font size in the Notes field, is this possible?
    Maybe a script is needed?
    Thank you for your help

    #51323
    Surya Paidimarry
    Participant

    Dear Tapforms,
    I have two forms, namely Project and Tasks. I have a linked field called Project Name that connects the Projects form to the child form, Tasks. I’ve created a script to automatically generate a set of tasks. However, I need to update these tasks with the Project Name. I tried using Advanced Find and Replace, but it doesn’t display the linked field, which I learned is a limitation. Manually updating each task is very time-consuming. Could you please suggest how I should proceed? I’ll paste my code for populating the tasks below. Any examples or corrections would be greatly appreciated. I’m not a professional coder, but I can research and accomplish my needs by following examples. Thank you all for your support. Happy TapFarming!

    function Ais_Pum_Default_Tasks() {

    var title_id = ‘fld-a34e5fd309dc4a9385d4b44736547f96’;
    var priority_id = ‘fld-cf942f13d8f14338966a81ccdd30ad81’;
    var category_id = ‘fld-fe9f869cf75a484ab4e3ca70f4c3dc43’;
    var environment_id = ‘fld-4a3951d0ef7b4e24a7affbf0afdbe6e3’;
    var project_name_id = ‘fld-e63dc1cd09cc4448b5d9e92005cb2dcf’;
    var status_id = ‘fld-77ad662cdb234741a5aff92434f600ac’;

    var ServerRequest = form.addNewRecord();
    var InsConfPUM = form.addNewRecord();
    var CFOTool = form.addNewRecord();
    var LoadCustomizationPum = form.addNewRecord();
    var GeneratePreCompares = form.addNewRecord();
    var LoadBugsGenerateCP = form.addNewRecord();
    var PUMDMU = form.addNewRecord();
    var OutageDEVL = form.addNewRecord();
    var PUMDEVL = form.addNewRecord();
    var CheckDevArchiveQuery = form.addNewRecord();
    var RetroDev = form.addNewRecord();
    var OutageTest = form.addNewRecord();
    var PUMTEST = form.addNewRecord();
    var CheckTestArchiveQuery = form.addNewRecord();
    var HandOffCollegeTesting = form.addNewRecord();
    var TestingSignOff = form.addNewRecord();
    var CMticketProd = form.addNewRecord();
    var PUMPROD = form.addNewRecord();

    ServerRequest.setFieldValues({[title_id] : “PUM Server Selection”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “N/A”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    InsConfPUM.setFieldValues({[title_id] : “Install and Configure PUM”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “N/A”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    CFOTool.setFieldValues({[title_id] : “Configure CFO Tool in PUM”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “N/A”, [project_name_id] : “PUMXXX”, [status_id] : “Differred”});

    LoadCustomizationPum.setFieldValues({[title_id] : “Load Customization in PUM”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “N/A”, [project_name_id] : “PUMXXX”, [status_id] : “Differred”});

    GeneratePreCompares.setFieldValues({[title_id] : “Generate Pre-compares in PUM”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “N/A”, [project_name_id] : “PUMXXX”, [status_id] : “Differred”});

    LoadBugsGenerateCP.setFieldValues({[title_id] : “Load Bugids and generate Change Package in PUM”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “N/A”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    PUMDMU.setFieldValues({[title_id] : “Apply PUM on DMU”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92DMU”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    OutageDEVL.setFieldValues({[title_id] : “Send outage Notice for DEVL”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92DEVL”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    PUMDEVL.setFieldValues({[title_id] : “Apply PUM on DEVL”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92DEVL”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    CheckDevArchiveQuery.setFieldValues({[title_id] : “Run Archive query in Devl”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92DEVL”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    RetroDev.setFieldValues({[title_id] : “Hand off Dev to Development team for Retrofits”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92DEVL”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    OutageTest.setFieldValues({[title_id] : “Send Outage Notice for test environment”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92TEST”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    PUMTEST.setFieldValues({[title_id] : “Aplly PUM on test environment”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92TEST”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    CheckTestArchiveQuery.setFieldValues({[title_id] : “Run Archive query created by Cindy”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92TEST”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    HandOffCollegeTesting.setFieldValues({[title_id] : “Releae environment for college Testing”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92TEST”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    TestingSignOff.setFieldValues({[title_id] : “Testing sign off”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92TEST”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    CMticketProd.setFieldValues({[title_id] : “Open Change Management Ticket for Production move”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92PROD”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    PUMPROD.setFieldValues({[title_id] : “Apply PUM on PROD”, [priority_id] : “High”, [category_id] : “PUM”, [environment_id] : “F92PROD”, [project_name_id] : “PUMXXX”, [status_id] : “NotStarted”});

    document.saveAllChanges();

    }

    Ais_Pum_Default_Tasks();

    #51318
    Glen Forister
    Participant

    The problem of using a Form Copy to test scripts. The copy doesn’t have any data, and so that has to be imported via CSV file.

    The problem with that is the possibility of a missed comma in the data. I discovered that when I use a field with a Pick List (Multi-Value Popover) with more than one item, a comma is inserted. That creates problems with exporting and using CSV files. I tried to find a way to substitute something else like ” – “, or semicolon etc., but I couldn’t find a way to do that.

    Any suggestions?

    #51311

    In reply to: Group summaries

    Glen Forister
    Participant

    Thanks, I took the easy out and got my answers by exporting and using a spreadsheet to remove duplicates.  Interesting way to attack that problem.  I will try the script at a later date when I have a day to devote to that.

    BTW, this brings up the problem of using a Form Copy to test the scripts.  The copy doesn’t have any data, and so that has to be imported via CSV file.

    The problem with that is the possibility of a missed comma in the data.  I discovered that when I use a field with a Pick List (Multi-Value Popover) with more than one item, a comma is inserted.  That creates problems with exporting and using CSV files.  I tried to find a way to substitute something else like ” – “, or semicolon etc., but I couldn’t find a way to do that.

    Any suggestions?

    #51310

    In reply to: Group summaries

    Daniel Leu
    Participant

    The Javascript API doesn’t provide a way to work on groups. The script posted by JScott shows results on all records. This could be enhanced if you can define how the records are grouped.

    Another option would be to work on the current saved search. This would mean that you create a saved search for each group. Then you could replace var records = form.getRecords(); with var records = search.getRecords(); to get the results on the currently selected saved search.

    Oh, ignore the alert(output) command in the script since this is not supported. You could use Utils.alertWithMessage(), but that’s not designed to display multi-line results. The console is your friend.

     

    Cheers, Daniel

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

    #51309

    In reply to: Group summaries

    JScottA
    Participant

    Glen, I have not tested the answer below, but I hope it helps you. It is from the unofficial custom GPT, Tap Forms 5 Assistant. I suggest you work on a copy of your database when testing this. Good luck!

    To calculate and display the number of unique values for each field (e.g., “Class,” “Order,” “Family,” etc.) in your Tap Forms database, you have two options: either use the app’s built-in features for a manual method or run a script.

    Option 1: Manual Method Using Export and External Analysis

    1.Export the Data:

    •Use Tap Forms’ export functionality to export your data as a CSV file. Instructions for exporting are on page 126 of the Tap Forms manual .

    2.Analyze in Excel/Spreadsheet:

    •Open the CSV in Excel or another spreadsheet tool.

    •Use the “Remove Duplicates” feature for each column to count unique entries.

    Option 2: JavaScript Script in Tap Forms

    If you’d prefer an automated method, you can use Tap Forms’ scripting functionality (JavaScript API) to calculate the unique values for each field. Here’s a sample script you can use:

    Sample Script

    // This script calculates unique values for specified fields in the current form.

    function uniqueValueCounts() {

        var form = document.getFormNamed(‘Museum needs’); // Replace with your form’s name

        var fields = [‘Class’, ‘Order’, ‘Family’, ‘Genus’, ‘Sp’]; // Replace with your field names

        var result = “”;

        fields.forEach(function(fieldName) {

            var field = form.getFieldNamed(fieldName);

            var records = form.getRecords();

            var uniqueValues = {};

            records.forEach(function(record) {

                var value = record.getFieldValue(field);

                if (value) uniqueValues[value] = true;

            });

            result += fieldName + “: ” + Object.keys(uniqueValues).length + ” unique values\n”;

        });

        return result;

    }

    var output = uniqueValueCounts();

    console.log(output);

    alert(output); // Displays the result in an alert box

    How to Use the Script

    1.Go to the Scripts section in Tap Forms and create a new script.

    2.Copy and paste the above JavaScript code.

    3.Modify the form and field names to match your data.

    4.Run the script.

    The output will display the unique value counts for each field in an alert box and in the console.

    For additional details on scripting in Tap Forms, refer to the Tap Forms Scripting 101 Guide.

    If you need further guidance or customization of the script, feel free to ask!

    #51305
    Glen Forister
    Participant

    In the attached is my data with “show group summaries” selected.

    What I would like to have is a way to show the group summaries of each column (field) which is calculated to include the numbers of unique names for each field

    For example, how many different Class names, different Order names, different Family names, different Genus names, different Sp names.

    If that can’t be done, how do I get that information. It doesn’t have to show up on the screen but can I run a script to show me the results?

    I can’t write scripts so I would need help here.

    Attachments:
    You must be logged in to view attached files.
Viewing 15 results - 226 through 240 (of 2,950 total)