Yes that’s right. It’s good for showing the results of running a script. It’s displayed asynchronously after the script executes.
Good question about whether it is a form script or field script. It’s a form script (would updating a record in a field script make sense?)
I don’t want to loop through and find the record as I am scraping a website (for missing image data) and don’t want to run though all 1000 records and hit the website. On the Mac I was relying on the current record, I guess I can’t do that on iOS.
I will add an extra check box that I will set manually before running the script and then the script can search on that.
Thank you. I have tried:
Utils.alertWithMessage("almost done", record);
And it puts up a dialog box, but the script doesn’t continue after pressing OK.
Is it only intended to be used at the end of a script?
Hi Martin,
The promptForInput function was an old function that is no longer there for Mac or iOS. I inadvertently forgot to update the manual with the new Prompter() class API. I’ve fixed the documentation for that now. But I still have to implement that on the iOS version
The Utils.alertWithMessage('Script Run Complete!', 'Cool!!!!!'); function should work on iOS though. I just tested it and it does work.
Thanks!
Brendan
Hi Martin,
Is this a form script or a Script field?
If it’s a Script field, then record should refer to the current record.
If it’s a form script, then you’ll need to find the record you want to update within the script by searching for the right record by looping through them.
I have a test script that updates a record on MacOS Tap Forms, but it doesn’t update the record on my iPad.
Here is an example:
var field_id = ‘fld-43e292a99a1646f1b5574954169ab319’;
record.setFieldValue(field_id, ‘Martin’);
document.saveAllChanges();
Could you please point me in the right direction to get this working on my iPad (works great on MacOS).
The database was created on the Mac and shared to the iPad, then synchronised with Nearby Sync.
Also, does the concept of current record exist in iPhone scripts?
Hi Kenneth,
Which version do you have? You can do this on the Mac version by clicking the location button on the field in the record and then changing the coordinates in the field there. Plus you can edit the name itself on the record details view.
I suspect you could do it with a script as well.
The structure of the Location field value is a dictionary that looks like this:
{
altitude = "2674953.657398775";
heading = "-0";
lat = "50.337885";
lon = "-115.853054";
pitch = 0;
title = "4992 Falcon Dr, East Kootenay F BC V0B 1L1, Canada";
}
Not all values are required. The heading, altitude, and pitch values are just for supporting the 3D map view on the Mac version.
So ya, if you can generate a dictionary of values like the above, you could probably use it with the record.setFieldValue(fld_id, value); function.
Thanks!
Brendan
Hi Martin,
I haven’t written any code to enable access to the clipboard. I’m not sure that JavaScript directly allows that so I would have to write some Objective-C code that allows access to it.
Thanks,
Brendan
Location Field Editing
I use Tap Forms as a logging device to capture events that have date/time and location components. There is a problem with Apple Maps (and presumably with Google Maps as well) that it does not identify the correct address with the GPS coordinates. As an example, an event logged at my home places the address of my home over on the next block with a totally erroneous street address. Unless you have some secret mechanisms with Apple APIs to tweak this, I have found no other way. Locations are always wrong in any app that I use that captures location data.
So my question is about how to edit these erroneous addresses. Can you share what the internal structure of the Location field is. At a minimum there seems to be the text component that holds the found address. Then there are one or two fields to old the longitude and latitude as single data points, or as one data point.
Can these internal Location field structures be edited by either a calculation field or a script field? And if so, how.
Ideally, I would like to establish the coordinates of a GPS rectangle that surrounds my house at a reasonable distance. Then test the GPS coordinates populated in the Location Field. If these coordinates are within this pre-established rectangle, then reset the captured GPS coordinates to the one, and only, GPS coordinate for the center of my house. Then change the address portion of the field to the correct address of my house.
Is this possible within Tap Forms? Or does it involve exporting the database to Excel or some other tool and doing the edits there?
Thank you for your counsel.
Kenneth James
Is it possible for a JavaScript script to read the iOS clipboard?
I like to quickly note new entries in plain text in other apps (e.g. Drafts). I know there isn’t a full Tap Forms URL scheme at the moment, but the ability to run a form script that creates a record from the clipboard contents would be fantastic.
I hope it is possible,
Martin
Ps Setting the clipboard too would be great to send data to other apps, but that is of lesser importance
A Document in Cloudant nomenclature is equivalent to an “object” in Tap Forms. And by “object” I mean a form, a record, a field, a pick list, a category, a script, a layout, a layout item, etc. I call the entire database a document because that’s what it is for Tap Forms. A document file (with a .tapforms file extension) contains within it an SQLite database file and a properties file and all of the attachments you add to your database.
So each of those things needs to be less than 1 MB big in order to sync. So if a record is more than 1 MB, it won’t sync and you’ll get an error. But unless you are putting a ton of information into Note fields (or pasting images into them), you’ll probably be fine. Tap Forms shows how big the record is at the bottom of the record details view for precisely this reason. The size you see there is not including the attachment sizes.
Hope that clears it up a bit.
Thanks!
Brendan
Hi,
The Shortcuts support is specifically designed right now for using Siri to execute a Form script that you create in JavaScript.
For example, if you had an expenses form with a Saved Search that lists the expenses this month, you could ask Siri “This month’s expenses” which would execute a form script that returns those results to you within Siri.
You could certainly have Tap Forms create and edit records within a script, but Siri shortcuts executed like this can’t accept parameters. But if you needed to insert or update the same data for every execution of the script, then that would work. For example, if you go to Starbucks and you buy the same priced coffee every day, you could write a script to add an expense record for this and record a Siri command such as “Coffee Time” and have it execute a script called “Add Coffee to Expense” or something like that. Or even call the script “Coffee Time”.
You can have a script return any data you like. But I haven’t specifically tested it when using the Shortcuts app. It’s just calling a script via Siri at the moment.
If you go through the on boarding process again by tapping the bookmark icon on the Documents screen in Tap Forms for iOS and choose the Todo and Expenses forms, they will include a couple of form scripts you can try out.
Thanks!
Brendan
Hi Andrew,
I would recommend using a Saved Search to filter the records which have been checked. That way you can either decide to delete them all in one go or have access to them later on.
Alternatively you could use a Script field which will delete the record when the checkmark value changes.
The only problem with that is it wouldn’t update the list right away to remove the record. You’d have to manually refresh the list of records.
Hi Carol,
I’ve already added the JavaScript support to Tap Forms. I suppose you could do something to pull data into the parent record which you could then search on from the parent. You would just need to create a Script field in your form, write some code to extract out the data from the Link to Form field’s sub-fields, then return that value. It would display in the parent form. Then you could create a Saved Search that scanned that data. It would probably be for a very specific search that you’d want to do rather than being able to search any sub-field on the child form.
I haven’t written any code to create Saved Searches that can query the child relationships on a parent form directly.