Thanks for the example. I was able to adapt it to my form and when I run the script it returns the expected result, but it is not displayed in the script field on the layout. The console log returns this error:
s_Doc: TypeError: undefined is not an object (evaluating ‘med_doctor[0].getFieldValue’), column:25, line:3
s_Doc is the name of the script field.
var med_doctor = record.getFieldValue('fld-84c907c7af3c49daa19ca1e30975bc1b');
if(med_doctor){
var Name = med_doctor[0].getFieldValue('fld-b1cfe8adec9b4d7397683b068a262cc2');
Name;
}
med_doctor is the parent form and the var Name receives the correct value from the Name field of med_doctor.
The error does not show in the script edit window when the run button is clicked, it only shows in the console if I click the save button and then open the log.
I have attempted to create a script field to return the value from a parent record without success. Could you please give a sample of your script.
Thanks,
Ron
Hi Deborah,
The reason this doesn’t work the way you would like it to is because a Join Link Type works basically the same way as a Many to Many. That is, you can actually have multiple parent records that all join to the same set of child records using the Join fields.
So that means that a child cannot get access to just one parent record via the Calculation field.
However, this is possible by using a Script field and having Tap Forms get the first parent record from the array of parent records and then picking out the value for the field from the parent record.
Ah yes. The form.getFieldIds() method. I forgot about that.
You’ll see the File Attachment fields in your form appear on the left panel on the Script editor after the next update.
Well, it is still needed it seems. I’m not sure why yet. Because an NSArray in Objective-C is supposed to translate into a JavaScript array. But an NSDictionary just translates to a JavaScript Object, which I guess still needs to be stringified.
I was wondering how to get to the attachment ID…
Following scriptlet shows the filename of the first attachment.
var receipt_attachment_id = 'fld-8bbc0b1472a746cabc38f6d7ab045668';
var receipt = record.getFieldValue(receipt_attachment_id);
JSON.stringify(receipt);
var meta = receipt[0];
if (meta) {
meta.filename
}
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Guillaume,
I haven’t opened up the File Attachment field to the Script editor yet.
Did you get that field ID by changing the field type to something else and then changing it to File Attachment? Because for me File Attachment fields don’t show up in the list of available fields.
In any case, it should be an array of objects where each object is a dictionary.
I’ll have to do some tests with this though to see how I can open it up for scripting.
Hey there,
I’m trying to get an attachment’s filename as a string and then parse it using regex to populate new records. When trying to get the value of the field:
var attachments = 'fld-e4657ea48c5a4ff6b82ee2a3c43c96a8';
var fileObject = record.getFieldValue(attachments);
console.log(fileObject);
this outputs
[object Object]
How can get to the properties of that object to get the attachment’s file name? If the form I’ll be using, there will only be one file attachment per record.
The purpose of all this is that I’m trying to convert a file base invoice archive where file names were following a convention of type YYYY-MM-DD - vendor - amount.
Thanks!
-Guillaume
Hi Bryan,
You could add a Calculation field or a Script field to your Artwork Details form that returns the artist contact name and displays that. That would work without you having to do all that work.
Thanks,
Brendan
Hey TF Gurus! I’ve peeked at the template exchange and didn’t see anything. I’m embarking on a new TF database project: a repository for household expenses, specifically for organizing home-buying associated receipts (hooray!).
As a secondary purpose, I’d like to capture monthly expenses, likely through data-mining electronic downloads of my bank account.
My idea now is to use a similar framework as I have for my business:
Form 1: Companies
Form 2: Expenses
Form 3: Expense Categories
Picklist 1: Created from Form 3, used on Form 2
Form 1 joined to Form 2 on Company Name
Form 3 joined to Form 2 on Expense Category value
I’d consider myself a firmly average user of TF. I can code in Python, but don’t know any JS. Just looking for any friendly advice or ideas from other users, or inspiration to spend the time to develop some scripting knowledge, for example to automate the record creation from the bank download.
Thanks for reading!
It’s awesome that you’re getting use from Siri Shortcuts integration in Tap Forms. Sometimes you never know how things like that will be used when you build them. The Script field is a super powerful feature in Tap Forms now. So many different things you can do with it. If you have the know-how that is :)
Thanks Brendan
That video was very helpful in getting me this far. I’ve been using about a dozen Siri-driven shortcuts that Form Scripts which add new records to self-monitoring TF database – with values that are specific to the Script I evoke (through Siri). All good.
Hoping to turn each of them into IOS Shortcut buttons at some later time – Siri doesn’t work well in all scenarios, per background noise and social setting :)
thanks as always
Brex
Hi Brex,
Did you watch the video in the link I posted above? That basically shows how the Siri intents works. It works only with Form Scripts and not Field scripts.
I’m not sure about that error. This is the only thing I’ve found referencing that error:
https://talk.automators.fm/t/problem-running-from-shortcuts/2154/5
I’m not sure what I need to do yet to allow Tap Forms scripts to run from within the Shortcuts app. I’m sure there’s a bunch of work I have to do.
I’ll have to work on that.
Hi Brendan
I’ve made some handy voice-activated Siri Shortcuts that allow me to log things/create new records in TF. My use case doesn’t require input or a selection, I have several different scripts that add specific things, without interaction being necessary.
Not sure how to wrap each of these as a new IOS Shortcut button (which is even more convenient and accurate than Siri). IOS even “suggests” my Tapforms scripts, when I go to try to write a Shortcut, but it fails and can’t find explanation for error message on the web. “IntentsErrorDomain error 1307”
More work on your side required to enable TF scripts to work with the new Shortcuts (just as Siri-enabling was required)? Or am I doing something wrong?
thanks
Brex
Does anyone know how Tapforms (Ipad) can be loaded into Tapforms please. I’ve managed to get it as far as showing in Imports.
It’s an old format that was used (typically) for Windows Cardfile software. Or even a utility to convert my AZZ file into a CSV file?
Failing that – I’m currently designing a Tapforms database that holds the modules and descriptions of an online EE course I’m doing. I would like to have a link from the Tapforms record to open up this AZZ files as it’s a database of Electronic Symbols used in EE along with descriptions.
Don’t suppose anyone already has a template to save me reinventing the wheel?
Thanks
Dennis
Leave the Planet (tlalticpac) in a better shape than when you first found it
I’m Undead, I’m not Unreasonable (Dracula)