Script error: ReferenceError: Can't find variable: photo_database, column:33, li

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Using Tap Forms Script error: ReferenceError: Can't find variable: photo_database, column:33, li

Viewing 3 reply threads
  • Author
    Posts
  • October 10, 2018 at 9:46 AM #30982

    Daniel Leu
    Participant

    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.
    October 10, 2018 at 3:58 PM #30985

    Brendan
    Keymaster

    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.

    October 10, 2018 at 4:27 PM #30987

    Daniel Leu
    Participant

    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

    October 10, 2018 at 4:43 PM #30988

    Daniel Leu
    Participant

    It helps to define the result type as text! Working now :)

Viewing 3 reply threads

You must be logged in to reply to this topic.