This is my first Script Trial , so apologise for my n00bs qs
There are multiple prompter scripts floating on forum but I don’t know which one to pick up. I’ve tried to patch together adding a simple record in site_id but it fails
var site_id = ‘fld-790b9d32090d4fd1873119a3e6401ec6’;
function textPrompter(title, text=””) {
return new Promise(function(resolve, reject) {
let prompter = Prompter.new();
prompter.cancelButtonTitle = ‘Cancel’;
prompter.continueButtonTitle = ‘Continue’;
prompter.addParameter(text,’prompterVar’)
.show(title, ((status) => {
if (status == false || prompterVar == undefined) {
reject(‘Cancel’);
} else {
resolve(prompterVar);
}
}));
});
}
var newRecord = form.addNewRecord();
newRecord.setFieldValue(site_id, prompterVar);
textPrompter();
It is not that complicated! This is a form script that loops through all records. It reads that value of your note field, modifies it, and then writes it back. Additionally, it checks that the note field content is defined, otherwise further processing is skipped.
The script currently replaces all line-breaks with a whitespace and removes all leading and trailing whitespaces. As you see, you can use your regex in JavaScript as well :)
The only change you need to make is define the note_id constant according to your form script. There are several ways to get the id. One way is to click on the field name in the script editor, then select and copy the ID string that is displayed underneath all the field names.
function Remove_Spaces() {
const note_id = 'fld-xxx' // set note_id according to your form
for (let rec of form.getRecords()){
// get note field
let note = rec.getFieldValue(note_id)
console.log("Orignial note: " + note)
// Check that note is defined
if (note) {
// modify note (replace line breaks with
// whitespaces and remove whitespaces from
// both ends of string
let modifiedNote = note.replace(/\n/g, " ").trim()
console.log("Modified note: " + modifiedNote)
// save note field
rec.setFieldValue(note_id, modifiedNote)
}
}
document.saveAllChanges()
}
Remove_Spaces()
-
This reply was modified 4 years, 2 months ago by
Daniel Leu. Reason: replaced tabs with ' ' for better readability
-
This reply was modified 4 years, 2 months ago by
Daniel Leu.
-
This reply was modified 4 years, 2 months ago by
Daniel Leu.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
You would probably need to write a Form Script that looped through the records then fetched the values for the fields you want to trim and then use the JavaScript trim() function.
You can do this with a script field and the “child records loop” snippet applied to the field you’re interested in joining together. If you search the forum for “child records loop” you can find some similar examples and the intro to scripting video I did also covers using the child records loop to create a comma separated list.
Our office uses QuickBase as DB , low code application. One of it’s cool features is to summarise the linked records in parent table. Please see screenshot attached.
This feature can make exporting Linked Records much easier in one single excel or if Tap Forms already can do using script , please advise me
Attachments:
You must be
logged in to view attached files.
You have two parseDate methods and one will likely mess with the other somewhere. You will need to give them independent names and usually extract them at the top of the script (this is what Daniel was referring to). Perhaps name one parseDate and the other parseTime to reflect that it’s handling a time.
If you look at the earlier script I posted, I had parseDate prior to the Import_Passport method. If you do something similar with the parseDate and renamed the other one parseTime, it’ll make it a little easier to read and I think should fix the error you’re getting.
1. Conceptually instead of adding the photos to Tap Forms and leveraging the built in functionality which would copy the photo into the document, you upload it to a third party service like S3 that then hosts the file. That gives you a link to the file that you can then include in a website field within Tap Forms. If you have many photos of the same item, I’d suggest that you use a table field where each image file you upload to S3 becomes an entry (Daniel does this and posted one script on opening attachments easily from a table). The image hosting service is somewhat immaterial, so long as you get a link to navigate to it that works on all of your devices. I picked S3 because there are plenty of resources out there on getting started with S3 and it’s relatively inexpensive all told.
2. Yes, a single user with the macOS version of TF running on a single device can use the feature of the attachment field that allows you to do an “add file alias” which doesn’t trigger a copy of the file into the document however this doesn’t work properly when you move to another Mac and obviously can’t work on iOS. That said in the NAS use case if they don’t have concurrent editing on the NAS, it would probably be ok for it to be shared on the NAS rather than use sync directly but there are not protections against concurrent editing so it could ultimately end up corrupted.
This is I think the second or maybe third post recently where this has been raised but adding such a feature is non-trivial so might be something for a later version (TF6?) as it would require rethinking a little how attachments (photos and files in general) are stored and maintained. iCloud could also be an answer as well because I think it has blob storage though obviously that limits cross-user sharing as well plus is one of the more expensive platforms (plus you can only buy 2TB off them).
I have two issues, i can’t solve:
I have two forms (F1 + F2) and i’m importing via script from csv file. With F1 all fields with dates (e.g. 13.01.2022) are fine using Sam’s function parseDate. But in F2 it doesn’t work. Same format as above and it says “undefined”. What the hell?
The second issue i have is with time fields. The import file has entries with time stamps (e.g. 17:43:56). Could these fields also be handled as dates? Is there a similar function?
Thanks for your help…
On iOS when you have a record open you can do “Copy Record Link” via the hamburger menu on the top right to take you back to that record. On the Mac, “Copy Record Link” is under the Edit menu.
The format is tapformz://record/view/[database ID]/[form ID]/[record ID]. The database ID is a unique identifier for your document, form ID is the internal identifier for the form and similarly record ID for the record. In addition to being able to use the UI to get the values, you can also use record.getUrl() via the Scripting API to chain actions together, embed into logs or use in field scripts. The JavaScript API also covers the ability to call into scripts in Tap Forms from external applications as well which gives you the ability to trigger form scripts with custom data. I have a video on how you can use this to integrate with Siri Shortcuts with barcode scanning of packages as a use case.
Sam, thank you very much for your script manager. It’s very cool! Have you ever considered including PapaParse? I think MIT-License allows that (https://mit-license.org)…
Great thanks to Brendan and Sam also from me for that script help… I had also this date issue and that date parse function works great!
BTW: Is ist possible to get the home directory name?
1. For the first one, if you’re using script or calc fields then they won’t be editable in the multicolumn view. The not visible could just be the field not being selected in your MCLV settings so make sure you check that. That said, if you want to edit the values differently from the model, it sounds like maybe you want to copy default values across which then you can edit later which would be a copying sort of use case? I have a video on a copying use case with link to form fields that might help.
2. The return Format is what is triggering the field ID to be displayed because your first line sets Format to the field ID, I’ll put a fix for your script below. If you’re using 1:M link to form (from what it looks like maybe not?) then you can use calculation fields to copy values. In this model I’d have a Link to Form 1:M from “Computer Models” to “Computers” with “Show Inverse Relationship” ticked which should let you get single values out.
3. I could have sworn that interface for existing records had a search box in it but that might only be on the Mac and not on iOS. That might also just be the single select side of the 1:M link type too.
4. If you fix the field that should fix the print.
This will fix the format being the field ID:
function getFormat() {
var Format = '';
var linked_model = record.getFieldValue('fld-a136f05b49a54749b15bedd371560ce1');
if (linked_model.length > 0) {
var first_contact = linked_model[0];
Format = first_contact.getFieldValue('fld-20f1f5ca216a4d7f8108f32be30c22d3');
}
return Format;
}
getFormat();
If you end up changing the link around to do 1:M from the Computer models and don’t use the calc field then you’ll have to change this to be just if (linked_model) and you can just use linked_model.getFieldValue.
Thx Sam. Sounds like a smart way to handle the relations. I will look into it and also watch your video.
Lets see if I (without any knowledge about programming/scripting) can rebuild this and update my TapForms. 😎
For the client who gave you a job that’s a Link to Form 1:M from Client to Job. Tick show inverse to make sure you can select Client from Job.
For the responsible team member at your client is a Link to Form 1:M from Team Member to Job. Also make sure you tick show inverse for similar reasons.
Team Member becomes a light weight form that is 1:M from Client to Team Member and 1:M from Contact Details to Team Member. This is a three form JOIN setup which I cover with a book use case. The video on using link to form fields to duplicate records might also help give you an idea. You can add extra fields to Team Member to control if it’s active or not and use scripting to update the data. You can also then use a JOIN type and calc field to filter data as well.
Check out the videos and see if they help connect some dots and when I’ve got some more time I might see if I can work up a more expanded example.
This may be a simple question, but how would I populate the current record’s ID into a field?
My objective is to make a printable label containing a QR or bar code with the link to the specified record, but I have no idea how to call the “rec-” value into a script or calculation.
All the posts I’ve found that seem to be relevant to this are directing me to a “Beta Team Membership” page.
Thanks in advance!