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,591 through 1,605 (of 2,989 total)
  • Author
    Search Results
  • #42756

    In reply to: Duplicating records

    Daniel Leu
    Participant

    TapForms doesn’t provide native support for this, but you can implement this using its scripting engine. Although my example shows how to copy data between documents where ALL FIELDS are identical, you can do this between forms as well. Again ALL FIELDS need to be identical!

    Details are at https://lab.danielleu.com/blog/copying-record-data-between-documents/

    Cheers, Daniel

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

    #42736
    Brendan
    Keymaster

    Hi Martin,

    Are you using the multi-column list view? If so, configuration of that is done separately from the single-column list view and the record details view. See this topic in the help manual for info:

    https://www.tapforms.com/help-mac/5.3/en/topic/multi-column

    Look for the sub-topic Editing the Multi-Column View.

    Perhaps that’s why you’re not seeing things sync up or some fields not showing up. You can control that all separately from the other views.

    Here’s a script to loop through the array of photos to get a list of the photo filenames:

    function Photo_Names() {
    	var photo_filenames = [];
    	var case_cover = record.getFieldValue('fld-54ed276ee9054d73843865f9c716e851');
    	for (var index = 0, count = case_cover.length; index < count; index++){
    		var photo = case_cover[index];
    		photo_filenames.push(photo["filename"]);
    	}
    	var filenames = photo_filenames.join(", ");
    	return filenames;	
    }
    
    Photo_Names();

    I’m not entirely sure what you want to do with them, but there it is. It will just log a list of the filenames.

    #42733
    martin c
    Participant

    ok …

    at first :: I select a cell >> then I have it in an form / a field property / the list view etc all the panels I can have for that cell/entry/single value .. it does not select on it own … so in every window/panel I have to scroll, choose the option/cell etc … disaster :) It should be all syncd to each other , so I select a cell or a position in a form and I get all the actual values in all panels like selection in all the current views/options >>> efficient workflow ??? bidirectional , no matter where selected from ….

    I have strange behaviour with the app … inconsistent … some fields showing up , some not , if I move the photo field on top it does not update in the list view etc … try to uninstall/reinst. the app … some liquid feeling :)

    ok … I give the script a chance :)

    thx …

    #42731
    Brendan
    Keymaster

    Hi Martin,

    When you edit a property for a field I do refresh the form because the changes you make do affect the display of the form. So that’s normal behaviour.

    I’m not sure about the photo field issue though. Nor the issue with jumping around when editing a property. Are you referring to the field properties not being the right properties for the selected field? I’m not seeing that behaviour.

    For the Photo field, you can’t reference a photo field in a formula.

    But you can in a Script field. A Photo field is basically an array of dictionaries. So when you ask the record for the value of a Photo field, that’s what you’ll get. There’s a filename property in the dictionary you can get to give you the value of the filename.

    Thanks!

    Brendan

    #42722
    Paul Wirth
    Participant

    Thank you so much, Brendan, for getting this feature started so quickly! Adapting your example, and after some messing around with the Mailchimp API docs and curl, I came up with the following:

    function Fetch_From_Mailchimp() {
    	var server_prefix = 'server-prefix'; // log in to mailchimp; the base url will be something like 'us19.admin.mailchimp.com'. in that example, 'us19' is the server prefix 
    	var api_key = 'mailchimp-api';
    	var list_id = 'id-of-audience-list'
    var response = Utils.getJsonFromUrlWithHeaders('https://' + server_prefix + '.api.mailchimp.com/3.0/lists/' + list_id + '/members?fields=members.id&count=10&offset=0', {"authorization" : "Basic " + api_key});
    
    return response;
    }
    
    Fetch_From_Mailchimp();

    This returns a list of the first 10 member id’s from the given list id.

    Next I’ll need to work on parsing member info through the API and updating the Tap Forms list. I’m a beginner with javascript, so that’ll be a learning project.

    #42698
    Brendan
    Keymaster

    I’ve been working on this (as a side project to the big project).

    Since I already have a Campaign Monitor account, I found they have a REST API too:

    function Fetch_From_Campaign_Monitor() {
    	var api_key = 'my-campaign-monitor-api-key:x';
    	var api_key_encoded = Utils.encodeBase64String(api_key);
    	console.log(api_key_encoded);
    	var response = Utils.getJsonFromUrlWithHeaders('https://api.createsend.com/api/v3.2/clients.json?pretty=true', {"Authorization" : "Basic " + api_key_encoded});
    	return response[0];
    }
    
    Fetch_From_Campaign_Monitor();

    Seems to work. I had to add the Utils.encodeBase64String() function because I couldn’t find a way to do that with JavaScriptCore.

    #42694
    Sam Moffatt
    Participant

    If you’re already doing local web development, just modify your scripts to call http://localhost in Tap Forms and call out to your local environment. Then you can use the scripting language of your choice in that environment to call in with the extra headers to the other APIs.

    #42688
    Daniel Leu
    Participant

    RE #2, if you implement your formula using a field script, then you have more control on the return value. There you can return an empty string instead of a 0.

    Cheers, Daniel

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

    #42659
    Eric de Mildt
    Participant

    Just new to Tap Forms, after using Filemaker for 25 years for small-business-accounting (self-employed free-lancer).
    As Filemaker is getting too expensive, and its iCloud-sync a real mess, I found Tap Forms just as good for my needs. And a really clear and flexible app to work with. Quite astonishing considering the price-tag and the fact it is written by (am I right?) just one person.

    Recreating (and improving) my old “system” was quite easy, I’d nearly say “a pleasure” ;-)
    I did have to spend a couple of days figuring out new ways for some things, and when and how to use the scripts, but after that importing 20+ years of Filemaker-data went nearly flawless.

    That’s why (now I start nagging ;-) I’m a bit disappointed by the lack of several features (and a little mistake) :

    – Custom Lay-outs on iPhone version ( As I’m on the road all the time, lack of this makes Tap Form a bit “unusable” for me as I can’t print and send on the go the most important thing: invoices and reminders ;-)
    I realize it’s not easy to implement but really would make Tap Forms perfect (for me at least ;-)

    – You have to set a default value for empty fields in a formula in order to get a result for a Calculation field. You can’t leave a field empty.
    Could there be a solution for this? (at least a possibility to Not Print Empty Fields for example? I had a look at script, did I miss something ?

    – And a little “mistake”: the Euro-symbol gets placed behind the number if Field/Currency setting is to Euro, and if OS system’s Region is set to, for example France or Belgium. (This OS Region setting needs to be correct for other apps).
    But in real life, we also put € before the number. So it’d be great to have that possibility.

    Anyway, keep up the good work!
    Eric

    Daniel Leu
    Participant

    Brent, great to hear that it worked, finally!

    Is there a way you can select the 1200 file records with the advanced search? If that’s the case you can select the saved search and just run the script with a little change:

    Before:
    for (contract of contractsForm.getRecords()){

    After:
    for (contract of search.getRecords()){

    It is strange to get the ’empty records’ notice although there should be a file associated with every record. That’s something I would look into.

    Fetching the file record might be what takes a bit of time. If you run this script frequently, it might be worth a try to save the PDF filename in a field and then just use this field in the comparison.

    Oh, don’t forget to backup your database, specially with so many entries!

    I might add a little sanity check as well to verify that a record was really found:

    		var success = 0;
    		// Loop over all contract records
    		for (contract of contractsForm.getRecords()){
    			if (!contract.getFieldValue(pdf_id) || contract.getFieldValue(pdf_id).length == 0) {
    				console.log('Record is missing PDF: ' + contract.getUrl());
    				continue;
    			}
    
    			// this assumes that there is only one PDF per contract!
    			var pdfName = contract.getFieldValue(pdf_id)[0].filename;
    			
    			if (csvPdfName == pdfName){
    				console.log("Found match: " + pdfName);
    				success = 1;
    				
    				// Update contract record
    				addKeyword(contract, keyword_id, entry.getFieldValue(csvKeyword_id));
    			
    				break;
    			}
    		
    		}
    		if (!success) {
    			console.log("No match found: " + csvPdfName, "#FF0000");
    		}

    Cheers, Daniel

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

    Brent S
    Participant

    Daniel and Sam,

    Thank you! Thank you! Thank you!

    Success!!

    Like Daniel mentioned in his original response, the process is a bit tedious. Indeed this is true, took my very fast computer (new iMac with 64G RAM) about 6 hours to complete this task. I was expecting about 6 minutes. So, I am going to need to find a more efficient way to do this. It might involve putting the full text of the PDF documents into a text field so that Tap Forms can just use its own search capability to pluck out keywords associated with a document within a record. (I also have full versions of all the contracts in HTML format which may be easier).

    It may also be there is a more efficient way the code could be written because I think this went though all 35,747 files in the main database rather than looking at the approximately 1200 files I wanted to tag. This was because I noticed I was getting many “empty record” notices in the console when I know for a fact each entry in the database has a PDF file in it.

    In any case, I am LOVING Tap Forms and looking forward to learning how to use these built in snippets along with customized scripts. Thank you Tap Forms community.

    #42631

    In reply to: Service Report

    Detlev Bonkamp
    Participant

    Hello Sam,
    thank you for your details information. Next weekend, it think, there will be enough time for me to create the forms an scripts like you showed it.

    Greeting Detlev.

    By the way, you pronounced my name in your video absolut correctly :-)

    Brent S
    Participant

    Hi Sam,

    Thanks. Almost there. So close I can taste it. See error message attached.

    I thought perhaps I am missing one line that starts with something like:

    var csvPdfName = csv.getFieldValue(csvPdf_id)[0].filename;

    However, I tried this and it did not work and just gave me another message “Category Script: ReferenceError: Can’t find variable: csv, line:(null)

    With respect to your question, there are 35,747 records. Each has one PDF associated with it.

    Cheers,
    Brent

    Attachments:
    You must be logged in to view attached files.
    Sam Moffatt
    Participant

    I’d also to check that there is a file attachment and skip ones that don’t:

    		// Loop over all contract records
    		for (contract of contractsForm.getRecords()){
    			// this assumes that there is only one PDF per recipe!
    			var pdfName = contract.getFieldValue(pdf_id)[0].filename;
    

    to:

    
    		// Loop over all contract records
    		for (contract of contractsForm.getRecords()){
    			if (!contract.getFieldValue(pdf_id) || contract.getFieldValue(pdf_id).length == 0) {
    				console.log('Record is missing PDF: ' + contract.getUrl());
    				continue;
    			}
    			// this assumes that there is only one PDF per recipe!
    			var pdfName = contract.getFieldValue(pdf_id)[0].filename;
    

    That should check there is an attachment and validate it’s not set plus log a message with a clickable link in the console. If that ends up being everything then that’s not great but it wouldn’t bomb part way through.

    There are 35,747 entries (PDF’s), so it is only one field, but there are many entries.

    Many records or a single record with multiple PDFs?

    Re feedback: The last few videos hit half an hour and I need to work on getting the content back in the 10 minute range. I ended up throwing a bunch of stuff in one of the videos which when I went back should have probably ended up broken out into a few videos (ended up putting in chapter links for at least one of them). I’m trying to keep them as continuous takes to make sure I don’t miss any steps along the way though sometimes that leads to mild confusion as it’s also not scripted/practiced. Sometimes seeing something small and seemingly unimportant is the hook you need to understand. Thanks for the feedback!

    Daniel Leu
    Participant

    In hindsight, it would have been better if you had described your problem as is and not made up this hypothetical recipe case….

    As you might have noticed, all CSV form related fields use the a csv prefix to make it clear where this field resided. And yes, my script is a from script that is part of the contracts form. My assumption was that the CSV form is deleted after use and recreated with a new tagging set. So it makes sense that the script has a more permanent location.

    Here is the updated script. Hope this works.

    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 csvForm = document.getFormNamed("csv");
    	var contractsForm = document.getFormNamed("Contracts");
    	
    	// recipes
    	var keyword_id = 'fld-a2126cbe512646e9ba144fb5a90b06dc';
    	var pdf_id = 'fld-3ea77ccc18604174b722ece105965c44';
    
    	// get csv field Ids
    //	var csvPdf_id = csvForm.getFieldNamed('PDF').getId();
    //	var csvKeyword_id = cvsForm.getFieldNamed('Keyword').getId();
    
    	// get use fixed field Ids!!!!!!!!!!!!
    	var csvPdf_id = 'fld-0cbd22a473cd4c58aa1dc47341a7157b';
    	var csvKeyword_id = 'fld-53de1c4c633a4da6a4d0213158b5ef0a';
    
    	// Loop over all csv entries
    	for (entry of cvsForm.getRecords()){
    		// get pdf file name of CVS record
    		var cvsPdfName = entry.getFieldValue(csvPdf_id);
    
    		// replace spaces with underscores
    		cvsPdfName = cvsPdfName.replace('/ /g', '_');
    		console.log("Processing: " + cvsPdfName);
    		
    		// Loop over all contract records
    		for (contract of contractsForm.getRecords()){
    			// this assumes that there is only one PDF per recipe!
    			var pdfName = contract.getFieldValue(pdf_id)[0].filename;
    			
    			if (cvsPdfName == pdfName){
    				console.log("Found match: " + pdfName);
    				
    				// Update contract record
    				addKeyword(contract, keyword_id, entry.getFieldValue(csvKeyword_id));
    			
    				break;
    			}
    		
    		}
    		document.saveAllChanges();
    	
    	}
    	
    	return 'done';
    }
    
    Update_Records();
    

    Cheers, Daniel

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

Viewing 15 results - 1,591 through 1,605 (of 2,989 total)