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 - 886 through 900 (of 2,989 total)
  • Author
    Search Results
  • Victor Warner
    Participant

    Brendan,

    Thank you for the response. It has forced me to find a work around.

    I know it is possible with a File Attachment field to click on the Add File icon (+) and then add as many files as you wish. However this is not reachable by the menu or by the keyboard – only a mouse or trackpad will work.

    I post the following in case it is of use to someone else.

    The workaround provides:

    1. selecting the record in Tap Forms
    2. in Finder, selecting the files to be attached.
    3. running a Keyboard Maestro macro using the For Each action which:

    (a) copies the filename and path of each file selected to the system clipboard
    (b) runs the Tap Forms Form Script (via a short AppleScript script) on each filename with path copied ot the system clipboard

    This is has the benefit that it can be activated via a keystroke and there is no need to worry about the names of files being different.

    The final Tap Forms Form Script is as follows:

    `function Add_Alias() {

    var ClipBoardName = ”;

    var file_attachment_id = ‘fld-1f7f08ca22de4884b5a7aa6b52a74251’;

    var ClipBoardName = Utils.copyTextFromClipboard();

    var url = “file://” + ClipBoardName;

    console.log(url);

    record.addFileFromUrlToField(url, file_attachment_id);
    document.saveAllChanges();

    }

    Add_Alias();`

    The Keyboard Maestro script is attached as a PDF.

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

    In reply to: Help with a script 3

    Brendan
    Keymaster

    They’re basically the same scripts, just one returns the Djur-ID and the other returns the Birth Date. You can only return a single value at a time, so two scripts are needed. One for each field.

    #47288

    In reply to: Help with a script 3

    Brendan
    Keymaster

    Ok, so you need two Field Scripts. One to get the maximum birthdate value. The other to get the Djur-ID of the calf with the maximum birthdate value.

    Here’s the first one:

    function MaxBirthDate() {
    
    	var kalvningar_id = 'fld-9107a2de427749e18f024644fd3cc1ad';
    	var födelse_id = 'fld-8e0cd05ffe8d4603a8abb8ca4694b4ee';
    	var djur_field_id = 'fld-1bb0eb29c4774502bf91c318093ae4f6';
    
    	var kalvningar = record.getFieldValue(kalvningar_id);
    	
    	var maxBirthDate;
    	
    	for (var index = 0, count = kalvningar.length; index < count; index++){
         	var födelse = kalvningar[index].getFieldValue(födelse_id);
    
    		if (födelse) {
    			if (maxBirthDate == undefined || födelse.getTime() > maxBirthDate.getTime()) {
    				maxBirthDate = födelse;
    			}
    		}
    	}
    	return maxBirthDate;
    }
    
    MaxBirthDate();

    Set the Result type of the above Field Script to Date.

    function MaxBirthDateDjurID() {
    
    	var kalvningar_id = 'fld-9107a2de427749e18f024644fd3cc1ad';
    	var födelse_id = 'fld-8e0cd05ffe8d4603a8abb8ca4694b4ee';
    	var djur_field_id = 'fld-1bb0eb29c4774502bf91c318093ae4f6';
    
    	var kalvningar = record.getFieldValue(kalvningar_id);
    	var calves_id;
    	
    	var maxBirthDate;
    	
    	for (var index = 0, count = kalvningar.length; index < count; index++){
         	var födelse = kalvningar[index].getFieldValue(födelse_id);
         	var djur_id = kalvningar[index].getFieldValue(djur_field_id);
    
    		if (födelse) {
    			if (maxBirthDate == undefined || födelse.getTime() > maxBirthDate.getTime()) {
    				maxBirthDate = födelse;
    				calves_id = djur_id;
    			}
    		}
    	}
    	return calves_id;
    }
    
    MaxBirthDateDjurID();

    Set the Result Type of the above Field Script to Number.

    That should do it.

    Thanks,

    Brendan

    • This reply was modified 3 years, 8 months ago by Brendan.
    #47287
    Brendan
    Keymaster

    Hi Goutalco,

    I would recommend compacting your database documents and see if that brings the file size down. It should also improve the performance.

    The size of the document may initially increase after you compact it, but when you close and re-open it, the size will be smaller again.

    Go to the Preferences window and then the Maintenance tab to find the Compact Database button.

    As for CouchbaseLite, I don’t actually use JavaScript to fetch data from it within Tap Forms. I use a mixture of Objective-C and Swift. Even when you use the JavaScript API that I wrote, those just call out to Objective-C and Swift methods.

    As far as accessing the database outside of Tap Forms using CouchDB, that’s something that Sam is way more familiar with than I am. My goal for Tap Forms was to take all of that complexity of a database engine away from the user and give them an easy-to-use front-end to the more complex SQL engine that powers it.

    Thanks,

    Brendan

    #47284
    Goutalco
    Participant

    Hello everybody,

    I’am new to Tap Forms 5 and have so far created two databases, one for fitness purposes and another to support my research in medieval philosophy.

    The structure of the first database is almost complete with data that tracks my activities for roughly two weeks. Its size amounts to circa 30 MB (no images or attachments) with no performance issues.

    The basic structure of the research database that comprises raw textual data of some central sources (no images , media or attachments) is more or less complete although it will presumably evolve in course of the research. Its size amounts to roughly 1.5 GB. Opening the default layout of some complex forms starts to be delayed (≈ 2 seconds).

    I think the size of the research database in a real working state could be easily 5 GB. So I like to know if I have to expect performance issues in the future.

    My second question relates to the document store (CouchbaseLite?) that underlies Tap Forms 5. I guess the structure of this store is the reason that queries are done with JavaScript rather than SQL.

    As Sam Moffatt pointed out in this thread you can can replicate all of your data into a CouchDB instance and get access to it there. What is a good starting point for a layman to learn more about the basic logic and structure of NoSql and specifically JavaScript-style queries and CouchDB?

    Cheers

    #47283

    In reply to: Help with a script 3

    Brendan
    Keymaster

    Hi Stig,

    I’m sorry but I haven’t had any spare time to work on your scripts for you at this time. I’ve been too busy working on the next version of Tap Forms. And I’m sure that Sam has been pretty busy lately too.

    You’ve said that you want to get the maximum birth date value. But I don’t know which field represents the birth date in which form. It’s all in Swedish and I just don’t know which field you need to birth date on and I don’t know which form you want it displayed in.

    Maybe I can help if you can translate your form to English for me and re-upload it here. It would certainly make it easier for me to write a script for you.

    But if it starts to get complicated with lots of back-and-forth messaging, then I’ll have to bow out for now as I really need to get back to working on the next Tap Forms version.

    Thanks,

    Brendan

    #47275
    Paul Kettle
    Participant

    Hi Yvette
    You are correct I’m on an Apple Macbook – so I don’t know if its possible to do all of the things on IOS.
    The transaction history is a table that sits on the form, I added a text field and then changed it to a table. Once you have it inserted into the form you can then add columns in the same way as you would with Excel.
    I’ve attached my progress thus far and will try and develop it a little further as time allows. However I’ve no experience of writing scripts, so not sure how much of a help I’ll be to your grand plan.

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

    In reply to: Help with a script 3

    Stig Widell
    Participant

    HELP!
    Is there anyone who could help a farmer with no knowledge in scripts?

    #47271

    In reply to: Creating a dictionary

    Goutalco
    Participant

    Hello everybody,

    Since the number of dictionaries is significant the import of images for every page of the dictionary blows up my Tap Forms 5 document to a size > 40 GB. So I opted for the second option, i.e. searching for a root and opening the dictionary as a PDF file.

    The solution suggested by Brendan by setting up a Website Address field which when clicked will launch the default PDF Viewer was not working for me. I got the following Error:

    
    The application “Tap Forms 5” does not have permission to open “Test.pdf.”
    

    So I found another solution which opens the PDF Viewer via a form script and tells the default PDF viewer to open the dictionary on the page that contains the term searched by the user.

    In case anybody is confronted with a similar problem, i.e. searching for alphabetically arranged items in PDF files, I share my script.

    
    var root;
    
    var user_input = function Show_Page(ok) {
    	if (ok == true) {		
    		// Variable for the record searched by root
    		var page_for_root;
    	    
    	        // Getting the pages (records) of the dictionary
    		var pages = form.getRecords();
    		
    		// Getting the id of the field that takes the 
    		// first root present on a page
    		var root_1_id = 'fld-8ab2fc88535e49dbb60df845f4157590';
    
    		// Getting the id of the field that takes the last root      
                    // present on a page
    		var root_2_id = 'fld-fa1b6724b80f4780b1779ab4ef098c75';
    
    		
    		// Looping through the pages
    		for (var index = 0, count = pages.length; index < count;
                    index++){
    			
    			// Getting the first root present the current page
    			var root_1 = pages[index].getFieldValue(root_1_id);
    			
    			// Getting the last root present the current page
    			var root_2 = pages[index].getFieldValue(root_2_id);
    			
    			// Compare root to root_1 and root_2
    			var compare_1 = root_1.localeCompare(root, 'ar')
    			var compare_2 = root_2.localeCompare(root, 'ar')
    
    			// Try to get the first page that contains root 
                            // and leave the loop in this case
    			if (compare_1 <= 0 && 0 <= compare_2) {
    				page_for_root = pages[index];
    				break;	
    			}			
    		}
    		
    		// If there is at least one page that 
                    // contains root, show the first one
    		if (!(page_for_root === undefined)) {
    		      // Getting the URI for the dictionary
                          // file (with appropriate page number) 
                          // stored in DevonThink
    		      var devon_id = 'fld-16ada2521a864aae8646222a6661a422';
        		      var devon = page_for_root.getFieldValue(devon_id);   		
        		      // Open the dictionary on the the requested page 
        		      Utils.openUrl(devon);
        		      // Go to the page (record) of the dictionary 
                          // in Tap Forms 5
        		      form.selectRecord(page_for_root);
      		} else {
      			console.log("Root not found");
      		}   
       } else {
              console.log("Cancel button pressed.");
       }
    }
    
    	
    function Search_Dic() {
    		
    	let prompter = Prompter.new();
    	prompter.cancelButtonTitle = 'Cancel';
    	prompter.continueButtonTitle = 'OK';
    	prompter.addParameter('Root: ', 'root')
            .show('Dictionary', user_input);
    }
    
    Search_Dic();
    
    Victor Warner
    Participant

    I wish to use the record.addFileFromUrlToField function to add an attachment to a File Attachment type field.

    The files are all named in a consistent way: year + job number + “invoice – invoice number” but then the invoice number various.

    An example:

    If the file is called: “2022_046 – Smith Consular Service invoice – invoice number UK144720.pdf”

    I can form the first part of the filename from a Tap Forms field (“2022_046”) plus the text upto the invoice number. It is the end part of the file name which I cannot form (“UK144720” in the above example) as it changes from file to file.

    The script I have come up with at the moment is:

    function Add_Attachment() {
    var file_attachment_id = 'fld-1f7f08ca22de4884b5a7aa6b52a74251';
    var protocol_number_full_file_naming_id = 'fld-cdbcef5028c54e8591313e2bc5295d1a';
    var protocol_number = record.getFieldValue('fld-cdbcef5028c54e8591313e2bc5295d1a');
    
    var url = "file:///Users/victor/Desktop/" + protocol_number + " - Smith Consular Service invoice - invoice number [ ].pdf"
    
    console.log(url);
    
    	record.addFileFromUrlToField(url, file_attachment_id);
    	document.saveAllChanges();
    
    }
    
    Add_Attachment();

    It is the part in “[ ]” in

    var url = "file:///Users/victor/Desktop/" + protocol_number + " - Smith Consular Service invoice - invoice number [ ].pdf"

    with which I would like to known if it is possible to use a wildcard/regular expression.

    Any help would be gratefully received.

    • This topic was modified 3 years, 8 months ago by Brendan.
    #47250
    Yvette M
    Participant

    Hi.

    If I’m not asking too much, could someone help me with the following database?

    Here’s the scenario:
    I am team manager for two girls soccer teams. Both are the same age group of girls, but one is the A team, the second is the B team. In our club, they are both 08(year they were born) teams and their team IDs are TK and NM.
    So the A team is 08 NM
    B team is 08 TK

    There are approx. 18 girls on each team and for the most part, the 08 NM roster always plays together, and the 08 TK roster plays together. When we play at tournaments, this can change. Some of the 08 NM girls may play for the 08 TK team, and vice versa. Also, we may have guest players.

    As a club, each player has club fees, uniform costs, and registration costs that should be the same for each player (but can be different).

    Also, every tournament has its costs that players are responsible for. I add all the costs, such as the tournament registration cost for the team and coaches travel expenses together and divide that figure based on the amount of girls going to the tournament. There will always be one registration cost per team for each tournament so that gets divided between the amount of girls in that team. But sometimes if both teams are going to the same tournament, then the coaches travel expenses will be divided by girls from both teams. So, for example, if the 08 NM and the 08 TK team are both going out of town to the same tournament, then we would all split the coaches travel fees. ($400 divided by 18 vs. $400 divided by 36)

    I want to be able to record these things:
    First, the players info. Name, team they are on, Jersey #, people related to them (I’ll explain why in a minute).

    Second, I want to keep track of Costs and Fees. I need to be able to list what fees are charged for each season. Examples: How much registration was, uniform was, etc.
    I want to know what tournaments we attended and what the cost was to be in the tournament. I want to be able to show who played at each tournament (that will give me the number to divide the cost by)

    Third, and most important, I want to track what each player owes and what each player was a part of. Somewhat an attendance record for each player.

    My main goal is to be able to say, Player 1 owes me $X amount of money. This is because Player 1 was in this tournament, which was on this day, and costs this much. I would like to be able to track each time Player 1 makes a payment, how much, for what, and her balance. A register of each players transactions so when a parent asks me “what do I owe” I can answer “you owe this much because of these reasons and you paid me on these dates so far”.

    Right now, my method is not great at all of keeping track and I am getting worried I am not going to be able to get on top of this problem if I don’t make a change now. That’s why I am begging for help.

    I accept payments from parents mainly through my bank and the parents use zelle. So, this is great because I can go back and look through transaction to see who paid when. But, I do this manually each time a parent asks and it’s so much work. I have to search for their parents name on the bank site( this is why I wanted people to record who is related to each player) so, maybe if was automated this task, I could pick Player 1 to find their payments and automatically it knows to include Player 1’s moms name and dads name into the search.

    Is there a way to use a script to automatically retrieve the statements from my bank (my bank allows downloads of statements in a .csv output that I can upload to tapforms.) and have 5he statements refresh and update each players payments log or record?

    I’m sure this was a lot to read and maybe too much to ask help with. But, if anybody can help and make my life easier while managing two teams, I know the staff , owner, and dedicated people who monitor these forums are the smartest people ever and can help me.

    There’s probably things I missed that may cause confusion, but please ask. I can better describe anything.

    Thanks for your time.
    Can’t wait to see if someone will help.

    Yvette

    #47236

    In reply to: Creating a dictionary

    Goutalco
    Participant

    Thank you Brendan,

    I converted all my dictionaries to images and using your hint I successfully imported these images to my document via a CSV file. This part was quite straightforward.

    Now I like to create a search inside a form script via the Prompter class and since my understanding of JavaScript is at best rudimentary I really appreciate any comment to the script that I was able to generate using the help file.

    
    var root;
    
    var user_input = function printOut(continued) {
    	if (continued == true) {
    	
    		var page_for_root;
    	       // Getting the pages of the dictionary
    		var pages = form.getRecords();
    		
    		// Getting the id of the field that takes the first root present on a page
    		var root_1_id = 'fld-e724350c999d4fddafc12d258d407a3c';
    
    		// Getting the id of the field that takes the last root present on a page
    		var root_2_id = 'fld-a01b915c72904b2caba68eb8c2657055';
    		
    		for (var index = 0, count = pages.length; index < count; index++){
    			// Getting the first root present the current page
    			var root_1 = pages[index].getFieldValue(root_1_id);
    			// Getting the last root present the current page
    			var root_2 = pages[index].getFieldValue(root_2_id);
    			
    			// Compare the root the user is searching for to root_1 and root_2
    			var compare_1 = root_1.localeCompare(root, 'ar')
    			var compare_2 = root_2.localeCompare(root, 'ar')
    
    		       // Try to get the first page that contains root and 
                           // leave the loop in this case
    			if (compare_1 <= 0 && 0 <= compare_2) {
    				page_for_root = pages[index];
    				break;	
    			}			
    		}
    		
    		// If there is at least one page that contains root, show the first one
    		if (!(page_for_root === undefined)) {
        		        form.selectRecord(page_for_root);
      		} else {
      			console.log("Root not found");
      		}   
       } else {
              console.log("Cancel button pressed.");
       }
    }
    	
    function Search_For_Root() {
    		
    	let prompter = Prompter.new();
    	prompter.cancelButtonTitle = 'Cancel';
    	prompter.continueButtonTitle = 'OK';
    	prompter.addParameter('Root: ', 'root').show('Enter a root', user_input);
    
    }
    
    Search_For_Root();
    

    Thank you for your patience.

    Cheers

    • This reply was modified 3 years, 8 months ago by Goutalco.
    Attachments:
    You must be logged in to view attached files.
    #47234
    Goutalco
    Participant

    Hello everybody,
    I like to create a dictionary database for classical languages based on some scanned dictionaries (19th and 20th century) that are available in the form of PDF files. The PDF files are not searchable and due to the mixing of several alphabets and diacritical characters present in these files ocr is not reliable (creating searchable PDF files would be very time consuming).

    The database should work with user input based on the roots of the language.

    Example for one PDF file. Let’s call the dictionary DIC and let ABC be a root.

    All entries in DIC pertaining to the Root ABC are present on a certain page of DIC.

    I have a list of all possible roots and the page number pertaining to each root, for example

    ABC: 23
    ACE: 51`
    BBD: 134`

    I like to create a Tap Forms 5 document which has one of the following two options:

    When the user searches for Root ABC, either

    1. Tap Forms 5 tells the Preview or any other PDF-Application to open file to open the dictionary DIC and show page 23,
    2. or a Form which contain all images of DIC opens record # 23.

    For performance reasons (the PDF files are quite large – several GB) I’am inclined to opt for the second option.

    So I have to create a form with a field that is able to accommodate photos obtained from the pages of DIC.
    My question is:
    1. How can I import thousands of photos into a Tap Form 5 form
    2. and how can I search for roots?

    The answer to the second question is probably connected to the Prompter class of the JavaScript API. But how can I import all the photos inside a Tap Forms 5 document?

    Cheers

    #47226
    Brent Willingham
    Participant

    Brendan,

    Thanks for the prompt response. The more complicated scenario, scenario 2, is what I’m looking to do. I have no experience with scripting, but looks like a fun challenge and this may be a good little project to practice on.

    Thanks again for the support, and I really love the App!

    #47223
    Brendan
    Keymaster

    Hi Brent,

    Cascading Pick Lists is something I’m working towards, but it’s not there yet.

    But within a Script you can set a Pick List on a field based on some condition.

    my_field.pickList = document.getPickList('Sub-Practice 1');

    The tricky thing about cascading Pick Lists are there are really two different ways to go about them.

    1. A simple hierarchical menu whereby you select the last level value and it gets entered into the field.
    2. A more complicated scenario where you select a value from a Pick List in Field A, then Field B’s Pick List changes to list only those values that are associated with the selected value in Pick List A. For example, select a Country, then the Province field’s Pick List changes to those Provinces which are relevant only for the selected country.
Viewing 15 results - 886 through 900 (of 2,989 total)