Need help accessing data from a linked entry field

87 views
Skip to first unread message

TC Freeman

unread,
Jul 15, 2022, 4:21:41 PM7/15/22
to mementodatabase
I need help trying to figure out how to access the data in a field in a secondary library.  I have an action script on the "Entry view card" in my primary library and need to assign the data from a field in a secondary library to a variable in my script. I have a "Link to Entry" field in my primary library that points to a record in my secondary library. I just need to assign the data from one of the fields in that secondary library record to a variable in the action script. I hope I have explained this.

I'm not sure if I should be using libByName() or just use field("Name of Link to entry") or both.

Bill Crews

unread,
Jul 16, 2022, 3:13:23 AM7/16/22
to TC Freeman, mementodatabase
If you didn't have the link-to-entry field in the primary library, then you can use libByName() to get the library object, but then you'd have to use one of the find methods or else do you own find by looping through the secondary library's entries to match to find the proper entry.

If you have the link-to-entry field in the primary library, then you can access the proper entry with...

entry().field(yourLinkField)[0].field(yourDesiredField);

As for whether to have the link, I consider a link-to-entry field to be appropriate when a normal, regular relationship (relationship == link in Memento) exists between the libraries. If not, then it's like reaching into a neighbor's things to fetch something you want. Not appropriate.

If anyone can tell me on what basis you'd want to take info from a library with which yours has no relationship, then I'll consider that and update the thread with my finding. It seems wrong to me.

On Fri, Jul 15, 2022, 4:21 PM TC Freeman <tcfre...@gmail.com> wrote:
I need help trying to figure out how to access the data in a field in a secondary library.  I have an action script on the "Entry view card" in my primary library and need to assign the data from a field in a secondary library to a variable in my script. I have a "Link to Entry" field in my primary library that points to a record in my secondary library. I just need to assign the data from one of the fields in that secondary library record to a variable in the action script. I hope I have explained this.

I'm not sure if I should be using libByName() or just use field("Name of Link to entry") or both.

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/242ab5db-0fe5-41b2-8f86-de268cabbd18n%40googlegroups.com.

TC Freeman

unread,
Jul 16, 2022, 1:17:41 PM7/16/22
to mementodatabase

Thanks Bill!

I have a link-to-entry field in my primary library so this code is exactly what I was looking for.
Reply all
Reply to author
Forward
0 new messages