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,576 through 1,590 (of 2,952 total)
  • Author
    Search Results
  • #42566
    Sam Moffatt
    Participant

    One of the workarounds I have for this is to leverage the built-in Apache web server and PHP which then handles the connections. It also makes it a little easier to work and debug because I can develop outside of Tap Forms and when I’m done, hook into Tap Forms. It gives me a lot more flexibility in coding as well because I have an entire PHP ecosystem to leverage. This allows hybrid functionality. It only really works on my own network or computer (depending on how I’ve done the scripts) but if that fits your use case it’s a great way to be able to handle more functionality in making web requests.

    #42564

    In reply to: Personel E-Mail

    Daniel Leu
    Participant

    You can do this with scripts. I posted this a while a go https://www.tapforms.com/forums/topic/creating-emails-from-tapforms/

    Cheers, Daniel

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

    #42558
    musicskidder
    Participant

    Thanks Dan, I suppose I can print a sheet of labels and make an entry manually. The ease of juggling so many records would then be to scan the tapes and have a search bring up the record that matches.

    I have been looking at Pasamio’s barcode script video. It is a beginning…

    Thank you,
    Stan

    #42552
    Daniel Leu
    Participant

    Looking at the API example:

    curl -sS \
      "https://${dc}.api.mailchimp.com/3.0/ping" \
      --user "<code>anystring</code>:${apikey}"

    I don’t think Tap Forms can work with the Mailchimp API as user authentication is not supported with the current Tap Forms Javascript API :(

    Cheers, Daniel

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

    #42548
    Paul Wirth
    Participant

    Hi folks,

    I have a Tap Forms database where I track client info. Clients are also in my Mailchimp email list. I’d like to be able to have my Tap Forms database update itself with any changes (unsubscribes, new subscribers, email address changes, etc) on Mailchimp, and vice versa using their API.

    If anyone’s done this already, or something similar, I’d be grateful for any pointers. I have a beginner-level acquaintance with javascript—mostly in the sense that I am sometimes able to tweak existing scripts to do what I want. I’m not at all familiar with working with an API, however.

    Grateful for any help!

    Brent S
    Participant

    Thank you Daniel! This is great. I am glad to know this is possible. It is going to take me a little bit of time to figure out scripting, but you have given me a great start.

    My database is actually not a recipe database. That was just a simple example to illustrate the problem I have which is a lot more complex. Your answer will help me generate a solution.

    The documents (readable PDF’s) I am dealing with are unstructured contracts and each are about 30 pages long, and yes each has its own unique file name. I do have them all in HTML too, but I think that might be a bit much to have that much text in Tap Forms?

    So, just circling back to the one part of the solution, where I have a pick list with four choices, in my example, “Breakfast, Lunch, Dinner, Dessert” your code is as follows:

    // Set category
    recipe.setFieldValue(category_id, entry.getFieldValue(csvCategory_id))

    If I understand you correctly, I would put the word “Dessert” as one of the entries in the CSV file under “Category” and then this will overwrite it in the Pick List?

    Anyhow. Thanks again!

    Daniel Leu
    Participant

    You can import a csv file into a separate form and then use a script to process all records and update your reference records accordingly. Then you can assign values of meal choices accordingly and update your keywords field as well.

    But this seems to be a rather tedious job if you want to update all 50k food recipes in your Tap Forms database this way. I would start with looking into software that converts your PDFs into text files. Then you can add the content of your text files into fields inside Tap Forms. These fields are searchable, which makes it much easier to categorize your recipes. But yeah, it might be a challenge to convert your PDFs, specially if they were scanned and the quality is poor.

    But if you want to go the CSV route, I would create a spreadsheet with columns for PDF, Category, and Keyword. Here is my example:

    function addKeyword(rec, kw_id, kw){
    	var keywords = rec.getFieldValue(kw_id);
    	
    	if (keywords == undefined || keywords == ""){
    		rec.setFieldValue(kw_id, kw);
    	} else {
    		rec.setFieldValue(kw_id, keywords + ',' + kw);
    	}
    }
    
    function Update_Records() {
    
    	var cvsForm = document.getFormNamed("csv");
    	var recipesForm = document.getFormNamed("Recipes");
    	
    	// recipes
    	var category_id = 'fld-9828d73d445a4746a8dba4c0dac89716';
    	var keyword_id = 'fld-073ee12d29174c2eb64f7cf91f5bb383';
    	var pdf_id = 'fld-e870153bd0a647c9823ca998c213d1fd';
    
    	
    	// get csv field Ids
    	var csvPdf_id = cvsForm.getFieldNamed('PDF').getId();
    	var csvCategory_id = cvsForm.getFieldNamed('Category').getId();	var csvKeyword_id = cvsForm.getFieldNamed('Keyword').getId();	
    	// Loop over all csv entries
    	for (entry of cvsForm.getRecords()){
    		// get pdf file name
    		var pdfName = entry.getFieldValue(csvPdf_id);
    		// replace spaces with underscores
    		pdfName = pdfName.replace('/ /g', '_');
    		console.log("Processing: " + pdfName);
    		
    		// Loop over all recipes records
    		for (recipe of recipesForm.getRecords()){
    			// this assumes that there is only one PDF per recipe!
    			var filename = recipe.getFieldValue(pdf_id)[0].filename;
    			
    			if (pdfName == filename){
    				console.log("Found match: " + filename);
    				
    				// Update recipe record
    				addKeyword(recipe, keyword_id, entry.getFieldValue(csvKeyword_id));
    				
    				// Set category
    				recipe.setFieldValue(category_id, entry.getFieldValue(csvCategory_id))
    			
    				break;
    			}
    		
    		}
    		document.saveAllChanges();
    	
    	}
    	
    	return 'done';
    }
    
    Update_Records();

    The first row of my spreadsheet are the field labels: PDF, Category, Keyword. They are used to create the field names when creating a new form called csv upon importing your csv. The script is part of your Recipes form.

    This script assumes that the keywords are comma separated. Keywords are added to your record if new ones are found. The category field is overwritten!

    In order for the script to work, you need to update category_id, keyword_id, and pdf_id according to your recipes form.

    Hope this helps! Happy cooking!

    Cheers, Daniel

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

    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.

Viewing 15 results - 1,576 through 1,590 (of 2,952 total)