Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
November 8, 2019 at 11:48 PM #37946
In reply to: Mileage Tracker (Tap Forms 5.3)
Brendan
KeymasterHi Joshua,
That would require routing information. There’s probably a Google API you can use to get the mileage given two end-points. But you’d have to do some research on that. You can use a Script to call out to a web service API and get the results which you could then store back in Tap Forms.
The Scripts topic in the online manual has an example of calling an online UPC web service that retrieves movie details. It would give you an idea how to call out to a web service. You just have to find the right web service to give you the results you’re looking for.
https://www.tapforms.com/help-mac/5.3/en/topic/scripts
The script I wrote for this mileage tracker simply copies the odometer reading from the selected record to a new record, then selects the new record.
November 8, 2019 at 8:58 PM #37938In reply to: Mileage Tracker (Tap Forms 5.3)
Joshua Kroll
ParticipantThanks Brendan,
Different question: I’m not good with scripting, but I thought maybe something may already exist that takes this a step further. Do you know if there is a script that I can put in a preset “start” address so that when I put in the destination, the milage is populated automatically?
I do a LOT of driving and need to track the milage. Something that simple would be awesome!
Just started with the iOS version and am very impressed so far! Thanks for a great product and great support.
Best,
JoshNovember 8, 2019 at 7:31 PM #37935In reply to: Calling a script with an AppleScript
Sam Moffatt
ParticipantI had a play with this and decided to use the new 5.3.7 clipboard support. I broke it up into three scripts: a launcher form script called
Open AppleScript, the AppleScript itself and then aLand AppleScriptto print the record ID.I used
openUrland this seemed to work ok. I also added a file attachment to a form and then attached the app to it to see if this would get around the Mac file limitation. This seemed to work for me but I didn’t try a fully sandboxed MAS version.The AppleScript I converted into an application to let Tap Forms launch it. This seemed to work fine. I modified your script to not re-open the same document since in this case it was open already to start the script and opening the document again was causing TF to open the document twice.
The last bit just validates that the clipboard is fine. Obviously if you use the clipboard along the way it won’t work properly but I think for this use case maybe it’d be ok? Even if you did use the clipboard in your ApplesScript, you could format it in such a way that the Tap Forms script could process it and make sense of it.
Of course we could just wait for the next Tap Forms release where it’s fixed but where’s the fun in that?
The
Open AppleScript:Utils.copyTextToClipboard(record.getId()); Utils.openUrl('file:///Users/pasamio/Documents/argv.app/');The AppleScript:
tell application "Tap Forms Mac 5" set theDialogText to "Running AppleScript!" display dialog theDialogText set doc to document "Test-TemplateImport.tapforms" run doc script named "Land AppleScript" in form "AppleScript" end tellThe
Land AppleScriptform script:Utils.alertWithMessage('Remote ID', Utils.copyTextFromClipboard());November 8, 2019 at 7:10 PM #37933In reply to: Script to calculate percentage of ticked rows
Sam Moffatt
ParticipantA form script like this should do it (replace
check_mark_idwith your field ID):var check_mark_id = 'fld-acaa569a30294a02a26e6fb116781718'; var records = form.getRecords(); var checked = 0; for (record of records) { checked += record.getFieldValue(check_mark_id); } checked / records.length * 100November 8, 2019 at 3:59 PM #37926Topic: Script to calculate percentage of ticked rows
in forum Script TalkRoy McKee
ParticipantDoes anyone have a sample script to calculate the number of ticked check box rows as a percentage of the total number of rows?
November 8, 2019 at 8:53 AM #37918In reply to: Calling a script with an AppleScript
Daniel Leu
ParticipantHow about having one additional TF script that you launch before you start your Automator/AppleScript flow? In this script, you would store
record.getId()in a dedicated form ‘workaround’ with one field: currentRecordId. Then in your TF script called via AppleScript, first you would restore the current record based on currentRecordId fetched from the ‘workaround’ form.Again, this is only a workaround until TF sets
recordwhen being called from an external AppleScript.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 8, 2019 at 7:27 AM #37917In reply to: Calling a script with an AppleScript
Martin Inchley
ParticipantIsn’t that circular? I would need to know the record ID for the current record – but there’s no way of knowing what that is. I can only use this snippet if I know in advance which record I want to target.
I want to be working on a record in TF, and then invoke a workflow in Automator/AppleScript which involves a TF script referencing the TF record I’ve been working with.
November 7, 2019 at 12:31 PM #37905In reply to: Calling a script with an AppleScript
Brendan
KeymasterHi Martin,
You’ll just have to get the specific record first in the script:
var thisRec = form.getRecordWithId('rec-93d0352d75c64a638dced9515827ac95');November 7, 2019 at 9:19 AM #37902In reply to: Time delay in scripts
Grant Anderson
ParticipantAgreed! And yeah, I’m using it as a form script as it is post-processing hundreds of records based on web lookups.
November 6, 2019 at 9:36 PM #37890In reply to: Calling a field value from a record or another form
Sam Moffatt
ParticipantYou need to assign a variable which is the record from the other form first.
In the Script Editor, double click on the form name to get it’d field ID and then use
var otherform = record.getFieldValue('fld-id')to get the linked records. If this shows up in Tap Forms as a table then you’re going to get an array of records (1:M in the parent, M:M fields or JOIN fields), if you’re in the child of a 1:M relationship then you will get a single record (the parent).Then you can get the value of the fields from that record via the other form, e.g.
otherform[0].getFieldValue('fld-otherid').November 6, 2019 at 9:07 PM #37886In reply to: Time delay in scripts
Sam Moffatt
ParticipantEven if setTimeout existed, it’d require the Javascript execution to be fully async but that would then cause potential race conditions with other scripts executing and changing values. It might make sense for form scripts but making that async in an environment like Tap Forms is a recipe for hard to debug issues that would make any seasoned operations person have nightmares.
I have a similar use case of a large amount work that a form script is doing which pauses Tap Forms due to doing heavy network I/O. Some sort of progress bar interface that I could use to at least communicate where it’s at and maybe do a clean cancellation would be useful.
November 6, 2019 at 2:09 PM #37874In reply to: Prompter Question or Design Change
Brendan
KeymasterHi Rocky,
I have a script here which continues execution after the results of the prompter are determined. Perhaps this will help you with what you want to do:
var second_prompt; var output2 = function printOut2() { console.log('second prompt: ' + second_prompt); } var output = function printOut(continueClicked) { console.log(username + ", " + password + ", " + email_address + ", " + other_field + ", " + genre); if (continueClicked == true) { let prompter2 = Prompter.new(); prompter2.addParameter('Did it work?: ', 'second_prompt') .show('A second prompt', output2); } } var username; var password; var email_address; var other_field; var genre; var genres = ['Action & Adventure', 'Comedy', 'Drama', 'Horror', 'Science Fiction']; let prompter = Prompter.new(); prompter.addParameter('Username: ', 'username') .addParameter('Password: ', 'password', 'secure') .addParameter('Email Address: ', 'email_address') .addParameter('Other: ', 'other_field') .addParameter('Genre: ', 'genre', 'popup', genres) .show('Enter a Username and Password and Stuff', output);Basically when the first prompter is run, the output of that is the execution of the
outputfunction which creates another prompter. Then that prompter is displayed. And the output of that isoutput2. So that’s how you can chain things together using the prompter.November 6, 2019 at 10:04 AM #37860In reply to: Q about Fetch Movie Data from Web Service example
Daniel Leu
ParticipantI hope that one day I can use the
Prompterfor scanning items. Then things could be automated with a script.Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 6, 2019 at 9:06 AM #37856In reply to: Q about Fetch Movie Data from Web Service example
Sam Moffatt
ParticipantI’m not sure you can fully do what you need with a script right now, the scripting interface doesn’t have a way of scanning anything.
That said, what you can do is use the barcode scanner the search feature has to look up the record and if you had a checkmark for registration you could add a field script to watch that checkmark field and do what ever business process you need.
November 6, 2019 at 2:47 AM #37849Brendan
Keymaster@George, on the iOS version in the Script Editor, there’s a button on the toolbar just above the keyboard that kind of looks like a vertical set of boxes. Those are to represent fields. When you tap on that, Tap Forms will display the list of fields with a function selector for getting the field value or the field ID. When you tap on the field, Tap Forms will insert the variable into your source code, thus giving you the field ID or the value from the record and field that you’re looking for.
-
AuthorSearch Results