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,741 through 1,755 (of 3,110 total)
  • Author
    Search Results
  • Brent S
    Participant

    Hi Everyone. I am new to scripting, so want to see if this is possible. Imagine the following situation. You have 50,000 food recipes all in PDF form input into the Tap Forms Database, each PDF with a unique file name and in a field where it is a “File Attachment”. So, there are then 50,000 records in the db. Many fields have been added to the database, but are empty until you manually go in and populate them. Is it possible to use scripts to help populate the data?

    For example, lets say outside TapForms you use Spotlight on the iMac to identify 60 PDF’s (recipes) that contained the words “Gummy Bear”. You make an Excel File (.csv) with those 60 unique file names. Can you now write a script that would reference those file names in a .csv file, find/look up the specific records in tapforms where those files are attached and then do two things:

    a) choose a picklist field that already exists, and choose one of the presets. For example, if this was a list of meal choices like “Breakfast, Lunch, Dinner, Dessert” the script would make it choose “Dessert” for each of those 60 records, but not any other records in the database

    b) If you had a textfile field named KEYWORDS then have it add the term “Gummy Bear” to the list of keywords again just for those 60 records

    If this is possible then I can see how scripting could help me and others categorize a very large database that would take a very long time to categorize manually. Any direction on what a script might look like would be extremely appreciated.

    Thanks,
    Brent

    #42524

    In reply to: Missing Field

    Daniel Leu
    Participant

    Patrice, just quoting Brendan from an earlier post:

    Hi Patrice,

    If you email me a backup of your document I can probably restore it.

    or check the “Restore deleted items…” function in the File menu to see if it appears there.

    Sorry for this trouble.

    Thanks,

    Brendan

    Brendan can be reached at support@tapforms.com.

    I have never encountered lost data as you describe it. Do you use any formulas or scripts that might have an unwanted side effect?

    Cheers, Daniel

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

    #42504
    Sam Moffatt
    Participant

    +1 to sometimes the GUI and the script engine have different views of the actual underlying state (generally the script is correct and GUI is out of sync).

    #42501
    Daniel Leu
    Participant

    The first version of the code was missing the form.saveAllChanges();. The second version of your code will delete all records that have the same naam. This might not be what you want.

    I would update the first version with form.saveAllChanges();. Sometimes the TapForms GUI doesn’t refresh upon changes. So the record might be deleted but you just don’t see it. Try clicking on ‘recalculate formulas’ to get the display updated. This should be fixed in the future (https://www.tapforms.com/forums/topic/advice-on-script-triggering/#post-42484).

    Cheers, Daniel

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

    #42496
    Brecht DHeere
    Participant

    Thanks Daniel!

    I tried to set the scriptline for deleting the record in this place (see below) but the record is still there after I run the script until I refresh. Is this normal or am I doing something wrong?

    Thanks,
    Brecht


    async function myFunction() {

    try {
    await confirmExecution(‘Do you really want to delete the record?’);
    } catch (errorText) {
    // user clicked ‘No’
    console.log(‘cancelled’);
    return;
    }

    // user clicked ‘yes’
    // continue with function
    // main code here
    form.deleteRecord(record);
    console.log(‘continue from yes’);

    }

    myFunction();

    Attachments:
    You must be logged in to view attached files.
    #42491
    Daniel Leu
    Participant

    In the script editor, there is the Prompt for confirmation template. That’s a good starting point. For your example, I just changed one string:

    function confirmExecution(question) {
    	return new Promise(function(resolve, reject) {
    		let prompter = Prompter.new();
    		prompter.cancelButtonTitle = 'No';
    		prompter.continueButtonTitle = 'Yes';
    		prompter.show(question, ((status) => {
    			if (status ==  true) {
    				resolve('Yes');
    			} else {
    				reject(question + 'No');
    			}
    		}));
    	});
    }
    
    async function myFunction() {
    
    	try {
    		await confirmExecution('Do you really want to delete the record?');
    	} catch (errorText) {
    		// user clicked 'No'
    		console.log('cancelled');
    		return;
    	}
    
    	// user clicked 'yes'
    	// continue with function
    	// main code here
    	console.log('continue from yes');
    
    }
    
    myFunction();

    Cheers, Daniel

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

    #42484
    Brecht DHeere
    Participant

    Hi,

    Why do I need to refresh before the record is deleted?
    I’m using a field script on the Mac version.

    Thanks,
    Brecht

    var checkmark = record.getFieldValue (‘fld-cf7c770a0bb04dc7922e79b24467bbd1’);
    if (checkmark) {
    form.deleteRecord(record)
    }
    form.saveAllChanges();

    #42446
    Sam Moffatt
    Participant

    I had an attempt at making a much in depth look at the script field and also the first snippet which is the if statement. I’m not sure if it hits the mark or not but I figured I’d start by working through each of the snippets but then after I’d done a few test attempts decided to spend a lot more time on script fields in general and some of their quirks.

    #42436

    In reply to: Students –Courses

    Sam Moffatt
    Participant

    Implementing that one is relatively straight forward, the child records loop does most of the heavy lifting for you. I need to go and time code the video but the intro to scripting video covers this (though perhaps I need to go take “simple” out of the title).

    #42435
    Brecht DHeere
    Participant

    New Feature
    OK, it will come…

    #42432

    In reply to: Students –Courses

    Brecht DHeere
    Participant

    OK, number 2 seems a good solution but I can’t write such scripts :(
    You don’t have a sample script that I can change for my form?

    #42431
    Brecht DHeere
    Participant

    Yes, when I refresh the data is ok. Sometimes I have to go to field view to refresh.
    It is not possible with a script to refresh that record? And is that a bug in TF?

    #42430
    Sam Moffatt
    Participant

    Every so often TF doesn’t refresh the calc/script fields after a script execution, at the bottom of the record is a refresh to recalc that record and at the bottom of the list view is another one that will apply to all records in the form. If you see a calc/script field that looks wrong, just hit the refresh button and see if it fixes it up.

    #42429
    Brecht DHeere
    Participant

    @Brendan: I figured it out already. New line in mailto: = %0A

    The button thing is not working because I don’t know if it is possible to send email with a script. But I’m using the globe of the Website Address field in my new layout as a button and that works fine :)

    #42426

    In reply to: Students –Courses

    Sam Moffatt
    Participant

    1. If you’re mapping multiple records together it’s the approach I recommend. You might end up wanting a fourth one to map courses to instances of the course that a student is enrolled in (sessions/semesters/offerings/something) but that might be going a bit too far.

    2. You could put a script field inside your link form that joins all of the students into the link form or the course form. If you did an enrolments script field on the course that joined the students enrolled in it and set it as one of the list fields then it’ll show up when you’re selecting courses.

    3. If you’re after a table of course to student list then the above script field should help there as well.

Viewing 15 results - 1,741 through 1,755 (of 3,110 total)