Hi
I have the parent database “Photo Database” with the child “Photo Prints”. The child database is used to keep track of all prints created and sold. In there, I would like to include some basic information from the parent database such as image title.
In the parent database I set the one-to-many link and enabled show inverse relationship. Then in the child database I created a field with the type ‘script’ containing
var image_title = photo_database.getFieldValue('fld-a64a1b71aeb8408499143d9c852b0056');
image_title;
But when I run it, following error:
ReferenceError: Can't find variable: photo_database, column:33, line:1
I guess I’m missing something to define photo_database which is the parent “Photo Database”. Attached is the sample template. Thank you for your help!
– Daniel
Attachments:
You must be
logged in to view attached files.
Hi Daniel,
Yes, Tap Forms needs to know what photo_database is.
What you need to do is double-click on Photo Database on the fields list on the left. That’ll put in the definition for that.
So you’ll end up with:
var photo_database = record.getFieldValue('fld-70bf5e5c35da46ab863690f617313d17');
var image_title = photo_database.getFieldValue('fld-a64a1b71aeb8408499143d9c852b0056');
I realize it’s not obvious that the parent field name is double-clickable.
Hi Brandon,
Cool! Didn’t think of that at all.
When I run it in the ‘edit script’ view, the result is shown in the Results field. I would expect to see this in the Title field in the Layout View too, but that remains empty.
Sorry for all the beginners questions!
Thanks!
– Daniel
It helps to define the result type as text! Working now :)