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.
Well that showed up… Ill ask my Question again.
I’m brand new to Tap Forms 5 – Still in the trial period – Using it on Mac
When I run the script to import a show it adds a record titled ‘No’ but no information is imported. If I try to run the script again on the script console log I get the error “series already exists undefined” regardless if it’s the same show or not.
URL Used: https://www.imdb.com/title/tt3107288/
Hi David,
I have a fix coming for this issue soon. Just working on an enhancement to the scripting before I can publish the update. Sorry for the trouble.
Thanks,
Brendan
Hi Sam, your approach sounds interesting for making a barcode search more convenient. Can you post your script and tell me where to place the script? I have no experience with the Tapforms script.
I am just wondering: My goal is to create a check in / check out workflow. If the script is already able to pull certain records using a workflow like yours, then could it also do the next step:
1. Prompt for an item barcode, then search for the record in the items form
2. Prompt for a box QR code, then associate it to the item
3. Go back to step 1, unless the user cancels the script by tapping on a “stop” button in the prompt.
What do you think?
An earlier iteration of my approach was to use ScanKey, a barcode scanning iOS keyboard, to scan input and process them. It’s a little clunky in that it jumps to it’s own app to do the scan, I remember needing to tap a button on it before it jumps back to the calling app. It has an OCR feature which is neat as well for when the barcode scanner misbehaved. It was annoying because you had to change the keyboard to activate it and changing the keyboard back, at least with my keyboard setup, was a little weird and it didn’t work properly.
First party support for barcode scanning in scripts would be neat though.
Prompter barcode is in my wishlist as well. I currently use Siri Shortcuts to scan a barcode, copy it to the clipboard, use a tapformz URL to get Tap Forms to open up the right document and form then use Run Script to execute a script. It pulls the barcode from the clipboard and uses that as input to the script. It works reasonably well though I wish there were a way I could directly invoke a script for a document/form/script combination and pass it in parameters.
Thank you for the adivse, Brendan. That helps to streamline my workflow a little bit. Daniel’s suggestion sounds interesting even though I have no clue about the scripting in Tap Forms yet.
Update:
hideField is a parameter to the field object and not to a fieldId:
var field = form.getFieldWithId(fieldID);
field.hideField = true;
Original response:
Two things come to mind looking at the script:
- you might need to run
document.saveAllChanges(); at the end of the script
- sometimes changes done by a script are not directly visible in the GUI, you might need to refresh the record by pressing cmd-r or clicking on the ‘recalculate formulas’ button.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
While I am not a javascript programmer, I can usually read through simple javascript code and understand what is happening. I am trying to write a simple script to show or hide a link to form field based on the value of a checkbox. Unfortunately it does not seem to be working even though it runs clean in the console log. Is there any quirky bugs in relation to scripts and link to form fields. I have included my simple script for reference. Thank you in advance for any assistance you can provide, it is greatly appreciated.
function New_Script() {
// get the check box id
var the_check_box = ‘fld-25afad2179224c368867d5f688afe496’;
// get value of check box – checked or not
var checked = record.getFieldValue(the_check_box_id);
// get id of the link to form field
var bills_id = ‘fld-3af9c9d4356a4dbba70d1e09a6ef6db5’;
// check if the check box is checked or not
if (checked == true) {
// true condition;
console.log (“show bills”)
bills_id.hideField = false;
} else {
// false condition;
console.log (“hide bills”)
bills_id.hideField = true;
}
}
New_Script();
It would be great to be have a barcode scanning feature using the Prompter(). Than one could write a simple script and have the automation done as needed. This would enable very efficient inventory updates, among others.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Paul,
You really don’t need a script to do this sort of thing if you’re using the Mac version.
There’s an Advanced Find & Replace function under the Records menu which would let you set a value in all of the records for a specified field.
You can also use the Fill Down function from the Multi-Column List View by typing your value in the field in the first row, then selecting that cell and all the cells beneath it and then using the Fill Down function under the Edit menu.
Do you have the Mac version?
Thanks,
Brendan
I wanted to add a new field to a form and have it set to a default value. I can do this with new records but I have over 2000 existing records and wanted to add this default value to the new field in each existing record as well. I assume the best way to achieve this is with a script but I am not great with scripting. I assume it is a very short script so was wondering if someone would be able to provide the script to be able to do this. I can see the setFieldValues function but don’t know how I write the scripting to be able to cycle through each record and populate the relevant field.
It sounds like you have two main data structures:
- A master list of all of your people/contacts, presumably with their email address.
- A set of email types or ‘campaigns’ that you want to send to a subset of your contacts.
There are a few ways I’d model this: a really simple way with a single form, a way with two forms and a slightly more complicated way with three forms.
The base are your people or ‘Contacts’ and you say you’ll have multiple email types/campaigns. You’re wanting to see all of the types/campaigns that the contact is available for as a property of the contact so you could model this as a single form with a lot of checkboxes at the end. Not the worlds most elegant solution but if there isn’t any more data than if they should get this email or not, then keep it simple.
Now if there are more details about the email type or campaign, then this would bring us to the two form solution. The second becomes your ‘Campaigns’ form and stores the campaign details. I’d model it so that you use a Link to Form field type set to Many to Many with the Show Inverse and then for each contact you add them to the campaign. Then the campaign can give you a list of all of the people who are supposed to be targeted to it. The campaign could also contain the body of the email you wish to send as well.
The challenge with this is exporting the list out to a CSV/Excel file means that the linked structure is flattened. You could work around this by putting fields in the contact form for each of the email types/campaigns but at that point you might as well just have a single form. For export purposes you could use a script field to automatically export a list of which campaigns the person is a member of but that’d require you to use Excel to expand the contents of the exported data as a post processing step.
This brings me to the third option which is using three forms. We keep our “Contacts” form for the contact details and we keep the “Campaigns” form for the campaign detail and then we create a third form for targets of the campaign, let’s call it “Campaign Targets”. In the “Contacts” form we create a Link to Form 1:M field pointing to our “Campaign Targets” field with show inverse relationship ticked and in “Campaigns” we do a similar Link to Form 1:M field to “Campaign Targets”.
Now to link a person to the campaign, we can create a new campaign target from the contact record and then select the campaign we want to use or vice versa we can create new campaign targets from the campaign and pick the people to include.
There are a few advantages of taking this approach:
- You can get either all campaigns a person is in or all people that a campaign is targeting by going from their respective forms creating a natural export filter.
- You can add calculation or script fields into the link form with content from either parent form (contact or campaign).
- You can export a flat list of contact to campaign easily and do filtering in third party tooling.
The first and third options achieve what I think you’re after without requiring a script field though you might want to use a calculation field to pull in the data you care about from the other two forms.
Hopefully this helps :)
I think you can do everything in your master form. In the master form, add a tag field of type text. Then you can add tags for the different member groups. Use commas or spaces to separate them. Then have filters for the different groups. This way, a member can take part of several groups.
I use something very similar with a custom layout. To assign a tag, I use a script with a Prompter where I use a pre-populated list.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks