Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
November 9, 2019 at 11:05 AM #37961
In reply to: Script to calculate percentage of ticked rows
Sam Moffatt
ParticipantIf you’re using a form script, then you’ll want to use something like
Utils.alertWithMessageto display it if you aren’t sending it somewhere else, e.g.:Utils.alertWithMessage('Calculation Result', checked / records.length * 100);Or to put that as the full script using your field ID:
var check_mark_id = 'fld-4cbc05636709431a8305cfb7739a9bc5'; var records = form.getRecords(); var checked = 0; for (record of records) { checked += record.getFieldValue(check_mark_id); } let percentage = checked / records.length * 100; Utils.alertWithMessage('Calculation Result', percentage); percentage;You can paste that into the script editor without having to define a function and it will work. The default Tap Forms script sample includes a function because otherwise some of the flow control keywords like
returndon’t behave normally.Also in the script editor when you run it, it should give you the output on the left or any errors n on the right.
Attachments:
You must be logged in to view attached files.November 9, 2019 at 10:55 AM #37960In reply to: Calling a script with an AppleScript
Sam Moffatt
ParticipantI used a file attachment field to get the file browser to prompt and select the file. Once you’ve done that, I think Tap Forms should have access to the file.
So create a form somewhere with a file attachment field, add to it your AppleScript app and then you should be able to execute it.
Also getting access to the latest beta should help you as well.
November 9, 2019 at 7:35 AM #37955In reply to: Script to calculate percentage of ticked rows
Roy McKee
ParticipantHi Sam
Thanks for the script. I have created it as you say, replacing the check-mark-id and field ref, thus:function Script_Google_No_1_S() {
// My Code
var Google_No_1_id = ‘fld-4cbc05636709431a8305cfb7739a9bc5’;
var records = form.getRecords();
var checked = 0;
for (record of records)
{
checked += record.getFieldValue(Google_No_1_id);
}checked / records.length * 100
Script_Google_No_1_S();
but nothing happens. Have I done something wrong?
November 9, 2019 at 5:44 AM #37954In reply to: Calling a script with an AppleScript
Martin Inchley
Participant@Sam I re-created your scenario with my own file names in place. The AppleScript triggers <Land AppleScript> fine. However, when I called the Run AppleScript script to start the process, I got an error from the Mac: ‘The application “Tap Forms Mac 5” does not have permission to open “(null).” ‘ Do you know where the permissions for that are set?
November 9, 2019 at 1:11 AM #37950In reply to: Mileage Tracker (Tap Forms 5.3)
Sam Moffatt
ParticipantI’d suggest looking at a tool like Automatic that will automatically record your trips for you. I bought a gen 2 model from them and it is generally gooda about recording trips and uploading them. Then you can export the CSV from the Automatic Dashboard and import that into Tap Forms as a set of records. Here’s a custom layout with a sample record from Automatic:

I went with an approach of splitting the start and end with their fields aligned at the top and the location fields immediately below it. This two panel style also naturally helps compact some of the other details. As you can see it sometimes doesn’t get the location fully detailed but the geo point generally gets it. In theory you can hook up API access to Automatic but I find you can export the data when you care about it. The JSON format has more data in it than what they export as CSV though but you can see it likely has what you need.
I’ve personally moved onto another OBD adapter that gives me a lot more low level detail but the Automatic adapter worked reasonably well for me for three years I was using it. They deprecated that Adapter and I chose to move on. The newer adapter gives me second level precision which is useful but creates really large log files. If you want a mostly turn key solution, Automatic is the way to go.
I’ve also attached my refueling log entries script. When I refuel my car, I write down the details from the car’s computer (trip distance, odo, estimated range (before and after refueling), MPG/MPH and drive time. Comes with a layout I use for side by side data entry. I use VueScan to do my initial import of the receipt which creates a new Tap Forms record I can transcribe the details from later.
Attachments:
You must be logged in to view attached files.November 8, 2019 at 11:48 PM #37946In 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'). -
AuthorSearch Results