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,666 through 1,680 (of 2,989 total)
  • Author
    Search Results
  • Chris Ju
    Participant

    Hello,

    has anyone tried to fill a fields in a Word file (template in Finder) with data from form fields using java script and adding this Word file to a record as file attachment?

    Is that even possible?

    Thanks.

    Chris

    #42276
    Sam Moffatt
    Participant

    Finally got around to recording the video for the barcode scanner. It walks through using Tap Forms on iPadOS to create a new form, create a new script that creates records for that form and then jumps over to Shortcuts to do the barcode scanning piece. From there you can use that shortcut on your home screen to quickly scan a barcode and import it into a Tap Forms record.

    #42264
    Brendan
    Keymaster

    There’s an example of fetching data for movies given an ISBN barcode number. This can be combined with barcode scanning so when you scan the ISBN number on the back of a movie disc, when Tap Forms saves the values, the script will be triggered and the movie details will be filled in.

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

    Look for Fetch movie data from web service to see the example.

    #42263
    Sam Moffatt
    Participant

    I don’t think there’s a post for the barcoding scripting stuff, I’ve been meaning to document it. I have one other thing on prompting I want to do and then something on my Siri Shortcuts to TF script work for shipment importing (scan tracking number, update existing record if match found or create new record for later handling).

    #42260
    Dustin Betterly
    Participant

    @sammoffatt, appreciate the comments input, and I apologize for any stupid questions I may ask. To start, I’m no programmer, so is there any where on this forum that documents the scripting process for barcodes/QRcodes?

    #42253
    Sam Moffatt
    Participant

    On iOS/iPadOS, there are a few places where a built in barcode scanner: you can use a barcode scanner to import into text fields and there is also a barcode scanner in the search boxes. Via the scripting interface, I’ve also leveraged iOS’ built in barcode scanner to quickly do a scan from shortcuts on the home screen and launch a script to do a search/import flow in the app.

    The multicolumn list view is the closest to a spreadsheet view but you can always export the data out to CSV for use in a dedicated spreadsheeting tool. The desktop has custom layouts but it is a little limited when it comes to making reports with nested data.

    #42203
    Sam Moffatt
    Participant

    Good to hear you got it sorted, recalculation is a little magical but should happen when the field changes. If you suspect something funky, you can always hit the refresh button below the record that will trigger a recalc of all calc fields in the record (script fields too). Sometimes useful for flushing out the gremlins.

    The script field is a front end to Apple’s JavaScript Core which is itself an implementation of ECMAScript 2015 (or later?). Script fields behave like calculation fields but execute Javascript and there is also a form script which can be executed on demand.

    Apple’s JavaScript Core doesn’t have stuff outside the ECMAScript standard that you’d expect to see commonly from web browsers but the core standard JavaScript is accessible. To interact with Tap Forms is a specific JavaScript API that gives you access to some of the internals of Tap Forms. I have some examples on my GitHub of JavaScript and there is also the Script Talk forum focused on JavaScript. If you’re a beginner, T. L. Ford’s got a Tap Forms Javascript Scripting 101 tutorial too.

    #42201
    Stefan de Graaf
    Participant

    Thanks for the help! Ah that was a copy-paste mistake indeed (older version of the script). I tried it with your version but keep getting the same “TypeError: undefined is not an object (evaluating ‘dataField.getTime’), line:(null)” error. And the date field is a regular date field (only the name has been changed) and has a date set. Will have to play around some more tomorrow.

    #42199
    Stefan de Graaf
    Participant

    Hey all,

    Hopefully a quick question: I’m trying something along the lines of this in a script field (based on a different date field):

    
    let dateField = record.getFieldValue('fld-060389f539934aa9b7163c7a8b7a4cd1');
    let delta = Math.abs(givenDate.getTime() - new Date().getTime()) / 1000;
    

    In JS, you can use getTime on a date object, but it seems you can’t do this with a Tap Forms date field’s value: TypeError: undefined is not an object (evaluating ‘givenDate.getTime’), line:(null)

    Is there a way to do this? Also tried creating a new Date() from the field’s value but that didn’t seem to work.

    Thank in advance!

    #42190
    Stefan de Graaf
    Participant

    Thank you very much Sam! Both suggestions seem to work now (figured out that the first one worked all along but apparantly it doesn’t always recalculate the value when you adjust the calculation. when I changed the Year field, it did show up.. oops..).

    And I didn’t even notice the script field (thanks for that suggestion!), otherwise I would’ve tried that as well. Might also be a nice way to generate text like “1 year, 10 months, 3 days ago”. Looks like it uses (some variant) of javascript, so that should be doable. Will try that tonight!

    Thanks again for the help and quick reply!

    #42186
    Stuart Devlin
    Participant

    Ok thanks. Am I able to write a script that would do that once a day? Do I take it that the reason Bento could auto update the calculation was because the database was shared from a single computer?

    This is not a huge issue at all, I’m just converting a Bento database that we use at work and it will end up being used by 3 or 4 people and the less anyone has to remember to do something the better.

    BTW, I LOVE how I can make this look so similar to my Bento solution, it’s really going to help with an easy transition for us.

    #42171
    Sam Moffatt
    Participant

    In Try 1 you have Year as a number (good) and Age as a date (incorrect). You need the calculation field to be a number because the ages is going to be a number. That said date should have still shown up but still been wrong. I copied what you put on the forum, replace “Year” with the field placeholder for my form and it works when set to number.

    In Try 2 you have an extra colon at the end of your calculation field. I created a date field and calc field also set to number which seemed to work properly for my tests.

    Calculation fields are a little touchy at times and can give you an empty result without any feedback. I generally prefer script fields because it’s a little more obvious what the error is, that said it’s not all that friendly:

    var year_date_field = record.getFieldValue('fld-060389f539934aa9b7163c7a8b7a4cd1');
    parseInt((new Date() - year_date_field) / 1000 / 60 / 60 / 24 / 365.25)

    Essentially we take the current date from the year_date_field (it’s a date field, a number field would need to be converted from a year to a date like the calc field does) and then that gives us the difference in milliseconds. We need to convert that to years which is the division operations there. The parseInt piece is to convert it to a whole number, alternatively you could replace parseInt with Math.floor as well.

    Hopefully that helps!

    #42133

    In reply to: Script stopped working

    Sam Moffatt
    Participant

    I don’t think Utils.alertWithMessage returns anything, it should block the script and continue executing on the next line, I don’t think it’s an async call but I could be misremembering. I have some prompter functions of my own (really borrowed/inspired by @daniel_leu) but I need to do some documentation work on them.

    I don’t think you can suppress the message, I believe it’s intended to be a security measure which is relatively common best practices these days.

    #42130

    In reply to: Script stopped working

    Sam Moffatt
    Participant

    Good to hear it’s working!

    I can’t claim credit for the Javascript guide though, that’s T. L. Ford’s (or @cattailnu) hard work not mine. It’s a great contribution though because whilst Javascript in Tap Forms is similar enough to Javascript at large, a lot of existing resources focus on the web (which has it’s own features added by browsers) or projects like node.js (also with it’s own quirks). Hopefully some Tap Forms specific resources will help the community at large.

    #42128

    In reply to: Script stopped working

    David Gold
    Participant

    I had one other question. I’ve changed the script to show the Comments field using alertWithMessage() (instead of copying to clipboard) and it’s working fine. If I wanted to then wanted to do something else after I’ve viewed the comments and pressed the “OK” button how do I do that? I can get it to work before I’ve pressed the OK but that doesn’t allow me to read the alert.

    Also one other question – if one wants to open an external URL is there anyway to stop the message coming up that you are leaving Tap Forms (on iOS) or is that built in as a security measure to the Tap Forms app?

Viewing 15 results - 1,666 through 1,680 (of 2,989 total)