I was also looking for a script way to set bold/italic.
My preference would be for:
setNoteFieldValue() to take 3 arguments where the last one is true/false for “am I providing HTML” with a default of false.
NSAttributedString ought to have a function for converting an HTML string. If it fails, it could just toss it in as plain text or throw the error with “dolt. format your html right” except said more politely.
As a random side note, my forum search turned up a post titled:
Feature request: markdown format support in notes field
which appears to be on the private Beta Team Forum (and clicking on it did not go to the post, but went to the Membership page header).
Which suggests you are already studying this puzzle, or have studied it, or have added it or decided it was more trouble than it was worth.
record.setNoteFieldValue() needs a ‘ in the example.
record.setNoteFieldValue(field_id, ‘note_value’);
This database is a writing tool that generates random plots that you can then use as a framework for your owns stories.
The derived data is based on the book, PLOTTO by William Wallace Cook, and the generated random plots cite the original text location by page, clause, and conflict.
From a Tap Forms perspective, the ‘Build Plot’ script shows how to use Configuration options that are stored in a form within your script, and how to add a record and make that record active when the script ends. It also demonstrates some JavaScript syntax for sorting, filtering, text substitution, and RegExp. It’s also got some pretty gnarly recursion.
Information and download here:
http://www.cattail.nu/tap_forms/plotto_william_wallace_cook_tap_forms/index.html
In search of non-script way to do case sensitive searches, preferably via regex support.
Would also like an easy way to do a simple group by query, returning a recordset of unique rows of just those fields. i.e. show me unique values for these fields (category, subcategory, etc.).
Would also like more sort fields, perhaps even named sorts, like there are named searches.
Thanks!
– T
Do you record multiple measurements for a contender or a single measurement record that is updated over time? If you’re not making multiple measurements for a single contender, I’d have a single form and use sections to group fields together which would side step the need for the script field.
Are the two forms linked? It almost sounds like birthdate only belongs in the contenders form, however, the thing you asked for would use a script field on your measurements form that finds the correct record on the contenders form and updates the field. Code to do that depends on if you have the two forms linked or not.
Did you see my scripting tutorial? Good intro level if you aren’t already a programmer, although it doesn’t answer this precise question. http://www.cattail.nu/tap_forms/tap_forms_scripting_101/index.html
Give us a little more information on how you have your forms set up so we can help.
I use 2 forms: one containing name and personal info (like date of birth) named <CONTENDERS> and a second one form containing info about personal measurements (name, length, weight, testscores, etc) named <MEASUREMENTS>.
I want to add birthdate in form <Measurements> automatically from the form <contenders> using a script. But I have no experience in building a script.
Can someone help me out, start me up
Thanks,
Hi Team – Is it possible to delete photos using a script? I didn’t see any methods in the Javascript API. I’m able to cycle thru the photo object, but could not find a method to delete a photo.
thanks,
rocky
Hi Brendan – The new feature you added on the preference UI. Can I access JSON files using the Utils.getJsonFromUrl function? I was trying the following syntx, but it was not working for me. Could you send me a snipet of code on how to use this new feature?
let response = Utils.getJsonFromUrl('/Users/alfredojmachado/Documents/sample.json')
console.log(JSON.stringify(response,null,4));
thanks,
rocky
Hello Ting,
i’m using TapForms with many forms (which are linked), really many fields (many calculations and scripts) and about 30.000 entries. So far I haven’t had any problems with poor performance or with synchronization (CouchDB via Docker).
Cheers
Chris
Thanks for the detailed description of the sync process Sam. Sam is exactly right in describing the challenges and the way sync works.
Sometimes things do get out of sync and one way to rectify that is to use the Send Document function to re-send another copy of the document over to your other devices. That assumes of course that you have a device which is the source of truth. It’s always best to have a single source of truth, such as Sam described with the star topology. The Mac is the source of truth and all the other devices sync to it.
If you don’t want to send the entire database over, you can also use the Export Tap Forms Archive command to generate a .tfarc file which you can import into another device. In that scenario, if there are changes or additions made to the form, records, fields, etc. then when you import, Tap Forms will apply those changes. It won’t delete anything though when importing a .tfarc file.
Sync is definitely a difficult thing to understand and to program. That’s why I initially chose CouchbaseLite as a database engine for Tap Forms 5. It contained within it the ability to sync using the CouchDB protocol and peer-to-peer syncing. So Tap Forms relies on that library to provide the syncing for those services. Cloudant also falls in that. Yes, IBM made it more difficult to setup, but it is possible and it does work, as long as you stay within their restrictions, such as records being less than 10 MB big (including attachments) and not storing more than 1 GB of data there.
And now Apple has thrown more curves at us developers by introducing the new Apple Silicon Macs and all the changes in Big Sur and iOS 14. So I’ve been focusing on making sure that I can get Tap Forms to run natively on Apple Silicon. I’m also investigating a new third-party sync engine framework which will hopefully allow me to bring back Dropbox syncing (as well as iCloud syncing) and possibly another sync service or two.
But this is a really big project for me, so it will take a while to build, then test, then fix, then test, and so on… until it’s ready.
Thanks,
Brendan
Bento only ever supported syncing from a Mac to an iPad and it was manual sync as well. Though you’re going between two devices and you’re cognisant of having to do the sync otherwise your changes didn’t get to the other side. You had to be aware of it and explicitly do it though perhaps for some folk that would make it more explicit if the same behaviour occurred with Tap Forms.
Multi master sync is hard, especially when you factor in sync failures, devices that might be offline frequently and conflicting edits. My understanding is that Tap Forms automatically resolves the conflicts based on the last record edited. However that can still inadvertently lead to data loss if you edit a record on a device, realise that it’s out of sync and then trigger the sync you will loose data. Last write wins is a common resolution strategy. An alternative would be having to manually reconcile every change and perhaps that’s an improvement but that could in some situations lead to hundreds or thousands of records being out of sync (an updated calculation or script could easily trigger changes to records).
iCloud Sync seems consistently problematic which in part makes sense because it’s backed by Apple’s notoriously finicky platform. Even Apple’s own apps mess up iCloud so I’m not surprised that Tap Forms has some challenges with the platform too. I am more curious about the Nearby Sync and Cloudant failures though.
For Nearby Sync I found quirks at times when everything talked to everyone because you’re basically inviting a race condition to occur. I did have some weirdness at times in propagation that generally got solved by moving it to a star topology where Tap Forms on my iMac had every other device added to it and then every other device only had the iMac. Nearby Sync works on a pull basis when the app is open and only when you’re on the same network, so it is actually easy to open up the app, make changes and realise that your device is out of sync. Nearby Sync I think is great if your devices are at a single location and you can have one instance of Tap Forms (I use a Mac but you could use any device that runs Tap Forms) open consistently for everything to sync against. If you have multiple devices and they aren’t always running Tap Forms when the changes are made then you will end up with situations where devices don’t have all of the changes because Tap Forms needs to be on at the same time on those devices for nearby sync to work.
The Cloudant/CouchDB side should make that better because it’s a hosted server model. Instead of having one Tap Forms app open all of the time, there is a server that is always on. That said if you lose connectivity to that server, you can’t push the changes but offline editing will still happen. There are a few situations where I believe Tap Forms will pause sync indefinitely depending on the error it receives (e.g. unable to connect to the server), that could trip someone up who is expecting it to be working but not realising it hasn’t been. This is generally easy to triage: on the Mac if you look at the bottom right after you make a change the “last uploaded” time should update and if you make a change on another device last downloaded should change; those same timestamps exist on iOS on the Tools tab.
Hopefully that helps folk out and make sync a little more reliable.
The reason it doesn’t autoupdate is because you’re obscuring the field ID’s and Tap Forms doesn’t know which field to watch. If you pull down on the record to recalculate the fields, it should update. Tap Forms is coded to look for the two placeholder templates and will use that to setup the links when those fields are changed.
In the script editor, there is a button at the bottom that will let you open a field list:

In this field list you’re given two options at the top, I’d go for the left one and then tap on the field you want. The right one will work but for this simple use case, I’d personally pick the left one:

That will put the getFieldValue call directly into your script and you can use it from there:

In your case it should simplify your script down to about three lines inside the function to just directly retrieve the field values and return their multiplied value.
Attachments:
You must be
logged in to view attached files.
Hi Sam,
Thanks so much for responding. However still the value of the Number3 field in the record is not changing when the Number1/2 fields are changed. Just for clarity my code now is:
function Number3() {
var Number1_field = form.getFieldNamed(‘Number1’);
var Number2_field = form.getFieldNamed(‘Number2’);
var Number1_ID = Number1_field.getId();
var Number2_ID = Number2_field.getId();
var Number1 = record.getFieldValue(Number1_ID);
var Number2 = record.getFieldValue(Number2_ID);
var Number3 = Number1 * Number2;
return Number3;
}
Number3();
(I changed the the expected value of the Number3 script field to be a number.) Any other ideas?
Thanks again …
Hi,
I’m trying to get field scripts to work (on iOS) and having little success. To simplify things I’ve copied some code from https://www.tapforms.com/help-mac/5.3/en/topic/scripts but can’t get it to output anything (when Number1/2 is changed). The exact code I’ve entered for the Number3 script field is:
function Number3() {
var Number1_field = form.getFieldNamed(‘Number1’);
var Number2_field = form.getFieldNamed(‘Number2’);
var Number1_ID = Number1_field.getId();
var Number2_ID = Number2_field.getId();
var Number1 = record.getFieldValue(Number1_ID);
var Number2 = record.getFieldValue(Number2_ID);
var Number3 = Number1 * Number2;
‘The total is: ‘ + Number3;
form.saveAllChanges();
}
Number3();
I’ve attached a screenshot of the form setup. Can anyone help me to get Number3 to change its value based on Number1/2?
Thanks alot.
Attachments:
You must be
logged in to view attached files.