AnonymousInactive
Hi,
I created a new table “AudioLog” for a new idea: I want to log audio information with the apple watch 5. My table has a field with date and time, a shot description (to fill in later) and a audio field. When I start the app on the watch with my table “AudioLog” an I press a button (<- that is the question, how I can realize start and stop/save on the watch with Tap Forms), then a new audio file will created an I can dictate my observation. When I press again, recording stops and save the audiofile and the table record.
How can I create the start stop save function on the apple watch 5?
Thanks for helping.
Actually, it seems like the Prompter isn’t working from the Script Editor. But it does work when you run it from the list of Form Scripts.
Did you execute your script from the “script edit” mode ?
From there Prompter did not show anything for me since I’m using it…
I my case the Prompter appears from the list or record edit view, but eg. getFieldValue returns “undefined”
Copy of the script:
var clipboard = Utils.copyTextFromClipboard();
if (clipboard)
{
clipboard = clipboard.split("\n")[0];
}
var tracking_number_id = 'fld-c487390743c947969cbe661cff596855';
var received_date_id = 'fld-e3e3539ee04f4cc7971c7098c572104d';
var confirmed_id = 'fld-2adb9ba8cdd048bbbb614d46b415ada5';
var alternate_tracking_numbers_id = 'fld-cf8718051bea4cc2aba0069ae76f32b7';
var alternate_tracking_number_id = 'fld-7342203d8f36415191bf8419fb6f70dc';
var callbackFunction = function(continued) {
if (continued)
{
let newRecord = form.addNewRecord();
newRecord.setFieldValue(tracking_number_id, clipboard);
newRecord.setFieldValue(received_date_id, new Date());
newRecord.setFieldValue(confirmed_id, true);
document.saveAllChanges();
}
};
function findRecord()
{
var targetRecord = null;
MainLoop:
for(candidateRecord of form.getRecords())
{
if (clipboard == candidateRecord.getFieldValue(tracking_number_id))
{
targetRecord = candidateRecord;
break MainLoop;
}
for (alternateRecord of candidateRecord.getFieldValue(alternate_tracking_numbers_id))
{
if (clipboard == alternateRecord.getFieldValue(alternate_tracking_number_id))
{
targetRecord = candidateRecord;
break MainLoop;
}
}
}
if (targetRecord)
{
targetRecord.setFieldValue(received_date_id, new Date());
targetRecord.setFieldValue(confirmed_id, true);
document.saveAllChanges();
form.selectRecord(targetRecord);
return "Updated existing record for " + clipboard;
}
else
{
let prompter = Prompter.new();
prompter.cancelButtonTitle = 'No thanks';
prompter.continueButtonTitle = 'Create record';
prompter.show("Unable to find matching record for " + clipboard, callbackFunction);
return "Unable to find matching record for " + clipboard;
}
}
findRecord();
Does record.getId() change between the main script and the async prompter callback?
I think Tap Forms has been generous with it’s updates as well, Tap Forms 5 came out in 2016 so that is a good three coming on four years since the last paid upgrade. It’s hard when you incrementally add features, at what point do you make the cut? What is significant enough to merit a paid upgrade?
To be honest the scripting upgrade for what power it grants should have likely been a paid upgrade. Then charts were added which is a great addition to the desktop version that helped me personally identify a bunch of dodgy records and clean them up. There is another scripting upgrade coming that whilst it’ll look small from the outside, I know was a lot of work to get right.
For me the amazing thing of being on the Tap Forms journey since TF3 is seeing how far it’s come. I was a Bento refugee to TF3 and there are still a bunch of features I miss from Bento (layouts on iPad) but with TF5 it’s managed to surpass Bento and in my mind is starting to catch up to File Maker, a product that is an order of magnitude more expensive. A richer report generation interface I feel could probably cause it to close most of that gap (and should be a paid upgrade).
Hi,
having issues since 5.3.8 (973) on iOS (iPhone):
I am in the record edit view, calling the script below with Prompter, it returns ‚undefined‘, but the field has a value:
function Test(){
var res = record.getFieldValue('fld-6f8227dc16204bd19dfb062a3dec8dc8');
Utils.alertWithMessage('Test', res);
}
var Note;
let prompter = Prompter.new();
prompter.addParameter('Note ?', 'Note', 'popup', ['Test 1', 'Test 2', 'Test 3'])
.show('Message prompt', Test);
By executing without prompter I get the correct field value.
function Test(){
var res = record.getFieldValue('fld-6f8227dc16204bd19dfb062a3dec8dc8');
Utils.alertWithMessage('Test', res);
}
Test();
I don‘t believe my script is wrong because it worked as expected in the past.
Hi Adrian,
The only way to achieve this would be to go directly to the Child form and filter the records there based on the parent. Then export your records. You’d probably need to create a Calculation or Script field which extracts a value from the parent to display in the list. This would only work if the relationships are one-to-many. Otherwise you’d have to write a Script to extract values if there are multiple parent records per child record.
Thanks,
Brendan
Ok. Thanks for the video. Now I see the problem with my code there.
I was accidentally passing in the wrong variable to my runScript method. I recently refactored it and mistyped the parameter name when called on the record details screen.
The next update will have it fixed.
Before when I tested it and it worked, it was because I was using the Mac version and didn’t notice that you were using the iOS version.
Hi Brendan,
it occurs when a record is selected.
The script below doesn‘t run in this error
when I execute it during edit the script.
It returns the title field value,
but it doesn’t change the color as well.
It occurs on iOS 13.2.3 (iPhone)
function Test() {
var title_id = 'fld-f7c25ccc01564c308c96fa08ca0da768';
var result=record.getFieldValue(title_id);
var color='0xFFFEFB00'
record.setRecordColor(color);
var color = record.getRecordColor();
console.log(result)
console.log(color)
}
Test();
Hi Marcus,
I just tested this out and it’s working for me. I first tested in my latest development build that I’ve made enhancements to the scripting engine. But then I tested it using the production version 5.3.8 and it also worked.
Make sure you have a record selected in your form before you run the script.
Since I‘ve installed 5.3.8 (968):
A simple script to read a field value runs in the following error by executing Run – Script (record view):
ReferenceError: Can’t find variable: record, column: x, line: y
When I execute this script in the „edit mode“ it runs without any issues.
function Test() {
var title_id = 'fld-76b2c64fccc34c20b62b7d485f5bfa28';
var result=record.getFieldValue(title_id);
console.log(result)
}
Test();
Hi Captain,
Sorry for not responding sooner.
I’m looking into this issue now. Originally I didn’t have the Contact field accessible in the list of fields on the Script Editor. But I’ve just added that now.
But I still have to look into what kind of information you can get from it still.
Thanks,
Brendan
Hi there,
I run a computer-repair shop and have been using tapforms to keep track of repairs, serial numbers, parts and prices and customer contacts.
I have about a thousand records by now.
I am using the Contact field type to input customer’s names, which works awesome: upon handing in a computer, i input their contact details in the Contacts app on my Mac, and afterwards, i can use the contact-field in tapforms to set up a new record with their name.
During a repair, i am sending status-updates to customers, at the moment i am manually typing these things and using text-expansion tools to rapidly get through standardized texts.
After reading up a bunch on scripting here, it seems to me it should be possible to use a script to send out standardized emails.
I have found so far that it should be possible to create a Web Site type field that is populated with info from other fields to create a mailto link (incl. subject and body info in html code).
However, upon attempting to write something i immediately got stuck because it looks like there is no way to getfieldvalues from a contact type field?
i know it should be possible if i create a separate field where i manually input each customer’s emailaddress, but that would mean an extra field entry.
Too long didnt read-version of my question:
Is there a way for a script to get values from the contact field type?
It’ll require a bit of customisation, I use this with shipping records to mark them delivered and confirmed (unconfirmed shipment delivery would be sync from automated systems). This is the one that grabs from the clipboard, looks for a candidate matching record and then updates it’s state:
var clipboard = Utils.copyTextFromClipboard();
if (clipboard)
{
clipboard = clipboard.split("\n")[0];
}
var tracking_number_id = 'fld-c487390743c947969cbe661cff596855';
var received_date_id = 'fld-e3e3539ee04f4cc7971c7098c572104d';
var confirmed_id = 'fld-2adb9ba8cdd048bbbb614d46b415ada5';
var alternate_tracking_numbers_id = 'fld-cf8718051bea4cc2aba0069ae76f32b7';
var alternate_tracking_number_id = 'fld-7342203d8f36415191bf8419fb6f70dc';
function findRecord()
{
var targetRecord = null;
MainLoop:
for(candidateRecord of form.getRecords())
{
if (clipboard == candidateRecord.getFieldValue(tracking_number_id))
{
targetRecord = candidateRecord;
break MainLoop;
}
for (alternateRecord of candidateRecord.getFieldValue(alternate_tracking_numbers_id))
{
if (clipboard == alternateRecord.getFieldValue(alternate_tracking_number_id))
{
targetRecord = candidateRecord;
break MainLoop;
}
}
}
if (targetRecord)
{
targetRecord.setFieldValue(received_date_id, new Date());
targetRecord.setFieldValue(confirmed_id, true);
document.saveAllChanges();
form.selectRecord(targetRecord);
return "Updated existing record for " + clipboard;
}
else
{
return "Unable to find matching record for " + clipboard;
}
}
findRecord();
This is a similar form script that uses the Prompter to ask for input and then creates a record:
// Order: Shipment Field ID
var shipments_id = 'fld-db2fcdb4d79c466ea09671c47d2ae645';
// Order: Ship Date
var ship_date_id = 'fld-6ab700ccc11d418fbd27d8899d00c7a9';
var ship_date = record.getFieldValue(ship_date_id);
// Shipments: Record Field ID's
var tracking_number_id = 'fld-c487390743c947969cbe661cff596855';
var carrier_id = 'fld-0950c430cb0c41f79c51d43a544b366b';
var shipping_date_id = 'fld-1aa32f17e059424fb4e24bf894b34fdf';
var callbackFunction = function() {
if (tracking_number && carrier)
{
var data = {
[tracking_number_id]: tracking_number,
[carrier_id]: carrier,
};
if (ship_date)
{
data[shipping_date_id] = ship_date;
}
else
{
data[shipping_date_id] = new Date();
}
console.log(JSON.stringify(data));
var shipmentRecord = record.addNewRecordToField(shipments_id);
shipmentRecord.setFieldValues(data);
document.saveAllChanges();
}
};
let prompter = Prompter.new();
prompter.addParameter('Tracking Number', 'tracking_number', 'text')
.addParameter('Carrier', 'carrier', 'picklist', 'Carrier - Shipments')
.show('Message prompt', callbackFunction);
The Prompter stuff uses a callback mechanism which means it’s not blocking so it takes a little bit of work to turn that into a continuous loop but it would be possible to do.
Creating a checkin/checkout flow is certainly possible though, not the most elegant but definitely possible.