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,341 through 2,355 (of 3,049 total)
  • Author
    Search Results
  • #37728
    Eddy
    Participant

    Hi Folks!

    Actually I am falling in love with this app… In the meantime, we are starting to create even our CRM with it.

    Doing this, I have a task/problem:

    Some text phrases and numbers of us will I have to change time by time. For example the footer of our emails. Of course, I do not want to rewrite all the scipt and calculation fields than. Therefore, I do not want to write our footer (signatures) text in the script and calculation fields directly…

    But how (where) can I store text phrases, so that they will be replaced everywhere I used them in scipt and calculation field, if I change them?

    Sorry for my poor English and thanks in advance.

    Eddy

    #37692
    Kimberley Hoffman
    Participant

    I’ve made this form to plan my blog and social media posts. The original is in my bilingual English/German = Denglish, but I have copied it and put the headings into English. You might have to adjust the lists, though. I’ve noted in those areas that you will need to work on to make it your own.

    Also you might want to adjust any bilingual entries. They usually are self explanatory; but, as I am an illustrator, some of the theme topics that are relevant to me won’t be of interest to you. And in the keywords section, you might want to change the last list entry of “language” to whatever language(s) you are targeting.

    I think the really nice part of this form is the part for the keywords search. Brendan had written a little script to change your keywords into hashtags. That makes it really convenient to copy and paste them into where ever your posting to. You can use the filter to search out the top 25 hashtags for yourself and your business.

    The forms aren’t styled any particular way, I found that these work best in their straightforward manner, but you can design them as you wish.

    Good luck and happy planning. If you like it, let me know. I would love the feedback.
    (You know, we could share styled forms on Twitter ( you can tag me @)visualitysenses and Instagram (@hoffmanillustrates).
    Regards,
    Kimberley

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

    I’d expand a little on Daniel’s approach and actually suggest two forms: one for your products and then a linked form would be the individual batches. The reason for that is that you can look up your products as top tier entries and then see all of the linked batches. I’d put the form script then in that product form and create a new linked record batch records that are linked. This will save you some database traversal where you’re only looking at linked records for the individual product. You could also do some more optimisation with extra lookup fields to speed up creating new records though you can iterate through record lists in Tap Forms pretty quickly.

    #37663
    Daniel Leu
    Participant

    Interesting question…. I would create a separate form that has fields for ProductID, Batch# and BatchUpdated (date). This is used to track the current batch number and when this batch number was last updated.

    In a form script that updates the batch number, I would check if the batch number was already been updated this month. If this is the case, then it is just a matter of incrementing the batch number. Otherwise, reset it to 1. At the end of the script, update the BatchUpdated field with the current date.

    When creating a new record for your production run, you can fetch the current batch number from the batch number form.

    Hope this helps!

    Cheers, Daniel

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

    #37661
    Daniel Leu
    Participant

    I’m wondering if you have to select a form from AppleScript first? But I don’t know how the syntax would look like.

    To get a valid record, the question is, which record are you looking for? The first one, a matching one, a new one?

    Here is the concept to get to the records without having a valid form. I assume that this is the case for your since you only open a document with AppleScript.

    var records = document.getFormNamed('form name').getRecords(); // get all records of given form.
    
    // loop over all records
    for (record of records){
       console.log(record.getFieldValue(time_id));
    }

    Cheers, Daniel

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

    #37659
    Martin Inchley
    Participant

    Thanks, Sam.

    Can you give me a syntax in AppleScript or JavaScript for selecting a record?

    #37656
    Ron Kline
    Participant

    Hello All!

    I’m trying to write script for a field that will auto populate a batch # for products being made. The format for the batch # will be Product ID #-MMYYYY-Batch #.

    Product ID # – this is a number I have already assigned to every unique product that can be made
    MMYYYY – this will be the month & year for when the product is made
    Batch # – I want this to be an auto-incrementing # that starts at 1 (or 01 or 001) for each unique Product ID # a record is created for.

    So, for example, the first batch of a product (lets say product 12) made in a month would have an overall batch # of 12-112019-1 (or 01 or 001). The first batch made for a different product (lets say product 25) would have an overall batch # of 25-112019-1 (or 01 or 001). The 2nd batch made for any given product would have the same beginning numbers as the 1st batch of that product but that last batch # component would increment to 2 (or 02 or 002) and so on. When a new month comes around that batch # component would reset back to 1 (01 or 001) for products made in the new month. So for the first batch of product 12 in the new month the overall number would be 12-122019-1 (or 01 or 001).

    I have been thinking about this for the past few days but have not come up with any ideas on how to accomplish it.

    If anyone has any advice or ideas I would appreciate it

    Thanks!

    #37652
    Sam Moffatt
    Participant

    Form scripts can be executed without a record being selected. What you’re running into is that there is no record selected and as such record is undefined.

    It’s more likely to be seen on iOS where you can run form scripts from the list view without anything selected but as you’ve found out it is also achievable on the desktop as well, just less likely.

    #37650
    Martin Inchley
    Participant

    Following an email exchange with Brendan, and some further unsuccessful experimenting, I tried to use AppleScript to open a script in a new, absolutely minimal database created for my other current query in this forum about scripting time data:

    Form Script “New Script” is:

    function New_Script() {
    
    	var time_id = 'fld-33fcface42864bf3801d7bf521c14e7f';
    	var thisTime = record.getFieldValue('fld-33fcface42864bf3801d7bf521c14e7f');
    	console.log(thisTime)
    
    }
    
    New_Script();

    When run, it puts a time value into the console (albeit, as discussed in the other thread, an hour earlier than the value in the originating field).

    However, when I use this AppleScript to call it:

    tell application "Tap Forms Mac 5"
    	
    	open "/Users/martin/Library/Containers/com.tapzapp.tapforms-mac/Data/Documents/Time testing.tapforms"
    	set doc to document "Time testing.tapforms"
    	run doc script named "New Script" in form "New Form"
    	
    end tell

    I get the following console message: “New Script: TypeError: undefined is not an object (evaluating ‘record.getFieldValue’), column:23, line:4”. Column 23 of line 4 is the dot in record.getFieldValue.

    I suppose this is an improvement on nothing happening (!), but I don’t understand why this should happen.

    #37639

    In reply to: Scripting Time fields

    Martin Inchley
    Participant

    I’m in the UK, and my Mac’s Date/Time is set to auto, which means GMT currently.

    Getting the time calculation right in this database is crucial, because the info will be exported to tell musicians what time to turn up for a gig! I look forward to seeing how you folks resolve these problems (opportunities!).

    So, related to this question – in fact the reason why I went down this path in the first place – is the issue of how you combine info from a Time field and a Date field to produce a Date
    object that can be entered into a Date & Time Field. I’ve tried all sorts of JavaScript instructions, but TapForms doesn’t recognise any of the results as a valid Date-Time that can be used to set a field. Is there a simple method? – something I’m missing, please.

    #37626

    In reply to: Scripting Time fields

    Daniel Leu
    Participant

    It shows 11:06:26 AM for me and the script reports Thu Jan 01 1970 11:06:26 GMT-0800 (PST).

    At a first glance this is okay, but the console reports PST instead of PDT. PDT is UTC -7. Now I’m confused too…

    Cheers, Daniel

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

    #37620

    In reply to: Scripting Time fields

    Martin Inchley
    Participant

    Thanks, Brendan.

    I’ve just created a new document – one form, one (Time) field, one script

    I used the field time tool to enter the current time (20:06:26).
    Running the script gave me a console output of “Thu Jan 01 1970 19:06:26 GMT+0000 (GMT)
    “, which is one hour before the field value.

    Document attached. I’d really like to know what’s going on!

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

    In reply to: Scripting Time fields

    Brendan
    Keymaster

    Time fields always set the date portion to 0 time, which is January 1, 1970. But your time zone can definitely change how that appears.

    When I added a script to get the time, this is what I get when I log to the console:

    Thu Jan 01 1970 12:41:38 GMT-0700 (MST)

    I had entered 12:41:38 PM into the field.

    The output of your script:

    function Time_Script() {
    
    	var time = record.getFieldValue('fld-58b1679f309d4e848f3aaf8f1d22da45');
    	if (time) {
    		console.log(time);
    		
    		var thisHour = time.getHours();
    		var thisMinute = time.getMinutes();
    
    		var newTime = thisHour + ":" + thisMinute;
    
    		console.log(newTime);
    
    	}
    
    }
    
    Time_Script();

    for me was:

    Thu Jan 01 1970 12:41:38 GMT-0700 (MST)
    12:41

    So the same time values.

    #37615

    In reply to: Scripting Time fields

    Martin Inchley
    Participant

    Daniel,

    I should, of course, have checked this first. The answer is that console.log(thisTime) reports “Wed Dec 31 1969 23:14:00 GMT+0000 (GMT)”. So the issue is with the first step (extracting the data from the Time field), not with the getHours() function.

    To be sure, I’ve just created a completely new Form, with one record, one field, and one script:

    var thisTime = record.getFieldValue('fld-7c2e0886dfa54aa59ffb75012ddd49b1');
    console.log(thisTime)

    I used the time tool attached to the field to enter the current time (17:22:50). Running the script output Thu Jan 01 1970 16:22:50 GMT+0000 (GMT) to the console.

    #37604
    Sam Moffatt
    Participant

    If you are pulling from a JOIN field, you need to get the records in that JOIN. JOIN is a many to many type so you will get multiple records back:

    var joinRecords = record.getFieldValue('fld-nameofjoinfield');

    This will return you a list of records that you need to iterate over. If you look in the snippet editor there is a “child records loop” snippet that should help you if you select the field you care about and then do something useful with it.

    Depending on your use case, the result of last line of your script field will be used as the script field value. If you’re looking to pull values out then you can just leave a line with the variable in it that you want to show up in the field.

    Here’s an example of how you can combine multiple values from child Link to Form fields into a single value, this feels like it might be pertinent to your use case.

Viewing 15 results - 2,341 through 2,355 (of 3,049 total)