Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Calling a child field value
- This topic has 5 replies, 2 voices, and was last updated 6 months, 3 weeks ago by Daniel Leu.
-
AuthorPosts
-
May 24, 2024 at 5:19 AM #50748
Chas Mac DonaldParticipantI’ve spent three days trying to do this, so if this is an annoyingly simple thing, I apologise!
I have two Forms – F01a and F04a
F01a has various fields, the important ones are MatTar and TarNam
F04a has various fields, the important ones are TarRef and TarClnI want to use F01a.MatTar to link to F04a.TarRef where equal and return Fo4a.TarCln into F01a.TarNam
I could this in MSAccess with my eyes shut, but I believe this is Java and I just can’t get it. I’m also working on an ipad 🙄
Save my mental health, pleeeeeez 🙂
May 24, 2024 at 9:14 AM #50751
Daniel LeuParticipantFirst you have to link the two forms. In F01a, create a
link to form
field and give it a name (eg link). Then set the link type tojoin
, select F04a as the form to link to and use the MatTar and TarRef fields for the values.Next turn F01a.TarNam into a script field. Following field script should do the trick. I have added comments to describe what I’m doing:
function getTarCln() {// get F014a formlet f04a_form = document.getFormNamed("F04a");// get field id for TarClnlet tarCln__f04a_id = f04a_form.getFieldNamed("TarCln").getId();// get field id for link fieldlet link_id = form.getFieldNamed("link").getId();// get linked recordslet f04a_recs = record.getFieldValue(link_id);// check that there's only one recordif (f04a_recs.length > 1) {console.log("Error, more than one record");return;}// get value from F014a formlet value = f04a_recs[0].getFieldValue(tarCln__f04a_id);console.log("Value fetched: " + value);// done, return valuereturn value;}getTarCln();This script assumes that the field that links the two forms together is calledlink
. You can change this on line 10.The return type of the script must match your field type, egNumber
,Text
,Date
.This is JavaScript and not Java. Although they share part of their name, they are totally different beasts.May 25, 2024 at 1:34 AM #50754
Chas Mac DonaldParticipantDaniel,
I’m a bit busy at the moment, so I’ll get a look at this as soon as I can. Meanwhile, thank you for your time and assistance. It is appreciated. 🙂
- This reply was modified 7 months ago by Chas Mac Donald.
May 25, 2024 at 9:12 AM #50757
Chas Mac DonaldParticipantDaniel, That all works fine, thanks … except that it does not put the value into the TarNam field where I want it. It’s in the results and console log, but not in the form field. Is there something missing?
May 25, 2024 at 1:38 PM #50758
Chas Mac DonaldParticipantUpdate: I got it to work 🙂 I have no recollection how 😂 But hey ho!
May 29, 2024 at 10:43 AM #50765
Daniel LeuParticipantHi Chas, thank you for letting me know that it works for you! Yeah!
-
AuthorPosts
You must be logged in to reply to this topic.