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 - 2,551 through 2,565 (of 2,948 total)
  • Author
    Search Results
  • #33928
    Kirk Williams
    Participant

    Thanks Brendan! Sorry, I’m very new to TF and am likely over-complicating this description. To hopefully clarify, what’s not updating is the picklist on the child form when additions are made to its linked parent form. So the parent has records “A”, “B” & “C” – all of which are available in the child’s linked picklist. When entering a record in the child form, I realize I need a “D” parent, so I go to the parent form (either using a new window or by switching to it) and add it. When I return to the child, “D” does not appear unless the entire TF file is closed & re-opened.

    #33883
    Brendan
    Keymaster

    Hi John,

    Tap Forms is doing the TOTAL() because you have a Link to Form field there and it doesn’t know which record to use, so the only choice is an aggregate calculation for the field from all the linked records.

    You’ll have to add your Calculation field to the Filament form instead. Make sure you have the “Show Inverse Relationship” option enabled. Now, if the relationship between your forms is a one-to-many then on your Filament form you can access directly the parent field’s Filament Used (mm) field to do your calculation. But if it’s a many-to-many or a Join Link Type, then that won’t work.

    With a Form Script or a Script Field you could write some JavaScript to pick out an individual record from the Cost per mm Link to Form field and then use that value in your calculation.

    Thanks,

    Brendan

    #33878
    Brendan
    Keymaster

    Hi Stephen,

    Excellent! I’m glad that has helped a bit.

    Tap Forms will write a bunch of the Script code for you by using the Snippets provided and just by double-clicking on the fields in the Fields list on the Script Editor. So you can do some basic stuff quite easily there.

    I know, easier said than done :) Hopefully it won’t be too difficult for you to learn a bit of JavaScript.

    Thanks,

    Brendan

    #33876
    Stephen Froggatt
    Participant

    Thank you, Brendan, very much indeed.
    Your reply is crystal clear and helps me understand better how the Linked Forms work.
    I have moved some of the fields around a bit on my forms so that they are now referenced in the correct direction. Everything now works as intended!
    You have also inspired me to learn some JavaScript programming in order to make use of “calculation fields on steroids!”
    Many thanks again for your full, prompt and helpful response.
    Every blessing,
    Stephen

    #33870
    Brendan
    Keymaster

    You can get what you want from the other direction, but not from the parent form. That is, on your Baby form you could add a Calculation field that references the Date Visited field from your Visit form.

    If you think about it, you have multiple visits, each with its own Date of Birth and Baptism Date. So which one do you want?

    The Calculation field is not able to reference an individual Link to Form field’s record.

    The Script field can though. To do that you would have to fetch the Link to Form field’s records, then pick out the first record and then do your calculation.

    #33859
    Richard Hassell
    Participant

    I need to make a field called full name that incorporates a first name field and last name field with a space between the names.. I use the script as below however as soon as I put a space between the ‘ and ‘ the program freezes and I have to force quit.

    function Full_Name() {
    var first_name = record.getFieldValue(‘fld-ee04b40fb2b64df5b26e7bf330e46657’);
    var last_name = record.getFieldValue(‘fld-f6c97003b1124b9ba8bd677d2142213f’);
    return first_name+”+last_name;
    }
    Full_Name();

    any advise?

    I am running : Version 5.3.5 (Build 943)
    on OSX 10.14.3 with latest updates as of today.

    Thanks Guys!

    #33852

    In reply to: label fix field length

    Brendan
    Keymaster

    Hi David,

    There are a couple of ways you can deal with variable width values for mailing labels.

    One option is to add a single static text object to your custom layout for your label and put the field names into it surrounded by square brackets.

    For example:

    [First Name] [Last Name]
    [Street Address]
    [City], [Province]  [Postal Code]
    [Country]

    When setting up your label this way, the width of each value doesn’t matter as it will accommodate the space required for the variable width values.

    You do have to make the box wide enough to accommodate the largest width label though.

    The other way to do it is to create a Calculation or Script field which concatenates the field values and then just place that one field on your label.

    See the Text Concatenation sub-topic in the Calculations topic in the online user manual:

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

    Thanks!

    Brendan

    #33847
    Kirk Williams
    Participant

    Thanks Brendan! I am currently using the shortcuts; with moving data into this particular form from other sources I’m using copy/paste a lot and thought it would just be a bit more ergonomic to have a quick-click shortcut to navigate records. I did add a script button to add a new record – that works well.

    Obviously no major big deal. I was just wondering if there was an easy way to script the prev/next functions for this particular case.

    Thanks as always!

    K

    #33844
    joe omalley
    Participant

    Hi B. Any chance of getting a video tutorial on how how to use a scripts. I’m a visual learning person. I’ll hang up and listen for your answer. Thanks

    #33832
    Kirk Williams
    Participant

    Greetings again,

    Is there a simple way to add navigational controls on a custom layout? I’d like to add some basic buttons to navigate to First, Previous, Next, Last & Create new records.

    I’ve tried adding a script for a keyboard shortcut, but TF will not allow me to use key combos that are already assigned. And as a disclaimer – yes, I know there is navigation in the app itself, but the prev/next buttons are relatively small and reside WAY too close to my auto-hide app bar when in full-screen… when adding records in bulk it becomes quite a nuisance.

    Thanks in advance!

    Brendan
    Keymaster

    Hi Victor,

    I’m sorry but I don’t have a feature like that at the moment. Although Tap Forms Mac can send an email either via the Print function when using Mail PDF to email, it won’t use an email address from the record to address the email in that situation. Or you can use the Email Selected Addresses feature to compose an empty email to the people with the selected email addresses in your records.

    I haven’t done a lot of work on the AppleScript support apart from executing Form Scripts from AppleScript.

    Thanks,

    Brendan

    #33796
    Kirk Williams
    Participant

    Thanks again for your help Brendan! I was able to make this work, although I likely did it in the most bone-headed manner possible (I hope to clean it up as I learn more about scripting).

    Just in case the reference may be useful to others, here’s the “solution” that produced the desired output:

    Each record in my form has four photo fields (“Photo1” – “Photo4”). How many of those fields are used varies by record, but every item must have at least one, and the photo fields are entered sequentially (meaning that, in theory, “Photo1” will never be blank).

    I also use an “Image Prefix” text field in which the URL is entered. This value only changes monthly, so I update the default value for new records at the beginning of each new month.

    With that in mind, I only altered the code you provided by updating the field ID’s and references and changing the URL reference from the static text to my “Image Prefix” field ID.

    function Photo_Links() {
    
    	var photo1_id = 'fld-b83135f083fe44b98835538c57a94834';
    	var photos = record.getFieldValue(photo1_id);
    	var links = "";
    	var image_prefix_id = 'fld-dea58cfd801f4e75882f397fc37a5df2';
    	var image_prefix = record.getFieldValue('fld-dea58cfd801f4e75882f397fc37a5df2');
    	
    	for (var index = 0, count = photos.length; index < count; index++){
    		var photo_data = photos[index];
    		var filename = photo_data['filename'];
    		links = links + image_prefix + filename;
    
                    // append a comma at the end of the link only if this is not the last link
    		if (index < photos.length - 1) {
    			links = links + ",";
    		}	
    	}
    	return links;
    
    }
    
    Photo_Links();

    The code above is used to populate a field titled “Photo1 Name”. I then replicated the same code to create fields referencing the remaining three photo fields (“Photo2 Name”, “Photo3 Name, “Photo4 Name”). For photos 3-4, I changed line 5 to insert a comma followed by a space instead of the original null value:

    function Photo_Links() {
    
    	var photo2_id = 'fld-e0aac08a96714b6390443627e49e73c1';
    	var photos = record.getFieldValue(photo2_id);
    	var links = ", ";
    	var image_prefix_id = 'fld-dea58cfd801f4e75882f397fc37a5df2';
    	var image_prefix = record.getFieldValue('fld-dea58cfd801f4e75882f397fc37a5df2');
    	
    	for (var index = 0, count = photos.length; index < count; index++){
    		var photo_data = photos[index];
    		var filename = photo_data['filename'];
    		links = links + image_prefix + filename;
    
                    // append a comma at the end of the link only if this is not the last link
    		if (index < photos.length - 1) {
    			links = links + ",";
    		}	
    	}
    	return links;
    
    }
    
    Photo_Links();

    With all four photo fields now populating exactly what I need, I just added a calculated field that returns the values of all “PhotoX Name” fields sequentially. Since the photo name fields return null values when there is no image, I’ve got a comma-separated list of each item’s photos that plays nicely with the Woocommerce import (essentially, I’m just prepending the comma rather than appending it based on logical conditions).

    I’m sure experienced scripters will cringe reading this lol… I’m always up for learning, so I’ll happily entertain any suggestions on how to clean this up.

    THANKS SO MUCH again for your help!!!

    K

    Victor Warner
    Participant

    Is is possible to send an email from/with Tap Forms using the contents of some fields of one record to populate the email. For example, an email field to be set as the recipient, another as the subject of the email, etc.?

    I hardly know AppleScript but I can see that it provides a way of automation the generating an email. But I cannot see in the AppleScript library for Tap Forms to way to address individual fields. But that could be because of my ignorance.

    #33786
    Kirk Williams
    Participant

    Thanks so much, Bendan – this is super helpful! One thing I neglected to mention is that the URL prefix is actually entered into a field on the form (since WordPress insists on creating monthly directories for uploaded images, I change the default value of this field at the beginning of the month). With that in mind, I replaced the static text in your code with a reference to the ID of the “image_prefix” field.

    The prefix seems to be working, but I’m still not getting the filename. It’s referencing a TypeError on line 9; I am going to continue to tinker and see if I can determine where I’ve thrown off the script.

    Once I get this working, my next challenge will be to include data from the other photo fields (“photo1”, “photo2”, “photo3” and “photo4”). Your code to append the comma for all but the last item is very cool!… I guess it’s time to start brushing up on my Java lol!

    Thanks again for your time – I will keep you posted on my progress.

    Attachments:
    You must be logged in to view attached files.
    #33785
    Brendan
    Keymaster

    Hi Kirk,

    You can accomplish what you want by using a Script field instead of a Calculation field.

    In Tap Forms, a Photo field is represented by an array of dictionaries that looks like this:

    [
          {
            "dimensions" : "{2048, 1536}",
            "filename" : "terminator-jugement-day.jpeg",
            "mimetype" : "image/jpeg"
          },
          {
            "mimetype" : "image/jpeg",
            "dimensions" : "{1280, 960}",
            "filename" : "hunger-games.jpeg"
          },
          {
            "mimetype" : "image/jpeg",
            "dimensions" : "{4032, 3024}",
            "filename" : "the-martian.jpeg"
          }
    ]

    Each of the things above are a dictionary that contains the mime type, the dimensions of the original image stored in Tap Forms, and the original filename.

    In a Script field you could have Tap Forms return a list of these images prefixed by a specific URL if you like.

    You would need to first get the value for the Photo field — which will be in the format like the above sample, then loop through the array picking out the filename from each Dictionary. A Dictionary is just like what you see above where there’s a key and a value. The key you want is filename and the value will be whatever the value is (e.g. the-martian.jpeg).

    Here’s some Script Field code which will do exactly what you need:

    function Photo_Links() {
    
    	var photo_field_id = 'fld-e2cf02f376864a7cb9f090e4a597f3e4';
    	var photos = record.getFieldValue(photo_field_id);
    	var links = "";
    	var link_prefix = 'http://mywebsite.com/wp-content/uploads/2019/02/';
    	
    	for (var index = 0, count = photos.length; index < count; index++){
    		var photo_data = photos[index];
    		var filename = photo_data['filename'];
    		links = links + link_prefix + filename;
    
                    // append a comma at the end of the link only if this is not the last link
    		if (index < photos.length - 1) {
    			links = links + ",";
    		}	
    	}
    	return links;
    
    }
    
    Photo_Links();

    You could just copy and paste the above into a Script Field in your form and then just modify the photo_field_id to match the ID of your own Photo field and the link_prefix to use the correct URL.

    Let me know if that works for you.

    Thanks!

    Brendan

Viewing 15 results - 2,551 through 2,565 (of 2,948 total)