Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Display a specific field value from a linked form
- This topic has 9 replies, 3 voices, and was last updated 2 years, 5 months ago by Daniel Leu.
-
AuthorPosts
-
June 20, 2022 at 8:28 AM #47509
angParticipantHello,
I’m trying to display the value of a specific field value from a linked parent form (many to many).
Name of the parent form : “structures_19_06”
Field ID value to display : “fld-33b8d7ca30f54c7f8e9974030ea1b3f0”In script, i have added the field like this :
function Structure_Diffuseur_1() {
var nom_de_structure = structures_19_06[index].getFieldValue(‘fld-33b8d7ca30f54c7f8e9974030ea1b3f0’);
}
Structure_Diffuseur_1()It returns thos error :
Structure (DIFFUSEUR) 1: ReferenceError: Can’t find variable: structures_19_06, line:(null)Can you help me to correct this ?
Thank you very muchJune 20, 2022 at 2:56 PM #47513
Daniel LeuParticipantIn order to get the field value, you need the form object from the parent form:
let formStructures_19_06 = document.getFormNamed('structures_19_06')
Then you can get the field value:
let nom_de_structure = formStructures_19_06.getFieldValue(‘fld-33b8d7ca30f54c7f8e9974030ea1b3f0’);
June 21, 2022 at 10:58 AM #47518
BrendanKeymasterDaniel, that code will get the form, but you still need to get a record.
But also because this is a many-to-many relationship, there can be more than one parent record. So you have to figure out which one you want.
June 21, 2022 at 11:47 AM #47520
Daniel LeuParticipant>>Daniel, that code will get the form, but you still need to get a record.
Oops… yeah, I overlooked that.
June 28, 2022 at 12:43 PM #47557
angParticipantThank you Daniel and Brendan,
I’m not sure that i understand correctly your answers.
I tried this :
——————————————————
function Structure_Diffuseur_1() {
let formStructures_19_06 = document.getFormNamed(‘structures_19_06’);
let nom_de_structure = formStructures_19_06.getFieldValue(‘fld-33b8d7ca30f54c7f8e9974030ea1b3f0’);
}Structure_Diffuseur_1()
——————————————————And i get this error :
Structure (DIFFUSEUR) 1: TypeError: undefined is not an object (evaluating ‘formStructures_19_06.getFieldValue’), line:(null)
Would you be able to help me ?
Thank you very muchJune 28, 2022 at 4:38 PM #47558
Daniel LeuParticipantAs Brendan pointed out, I overlooked a detail… with
document.getFormNamed()
you get the form object. But to usegetFieldValue()
, you need a record object. So that’s what I proposed doesn’t work. Sorry!Can you share your document? That might make it easier to help.
July 12, 2022 at 4:02 PM #47598
angParticipantThat’s very kind of you Daniel.
Here is the link for file :
https://fromsmash.com/baseexploI have attached a screenshot which explains the process.
I have rename the 2 forms so “formStructures_19_06” is now ‘Base-Diffuseurs’ :
Here is the code that does not work :function Structure_Diffuseur_1() {
let formBase-Diffuseurs = document.getFormNamed(‘Base-Diffuseurs’);
let nom_de_structure = formBase-Diffuseurs.getFieldValue(‘fld-33b8d7ca30f54c7f8e9974030ea1b3f0’);}
Structure_Diffuseur_1()I hope you can help me.
Many thanks in advanceAttachments:
You must be logged in to view attached files.July 12, 2022 at 11:37 PM #47602
BrendanKeymasterHi ang,
As Daniel mentioned in his response above, you need a record. You don’t have a record in your script. You’re attempting to get a value from a form. A form has no values. It does have records though. And records have values for the fields in the form.
So you need to modify your code to either use the currently selected record by using the
record
keyword, or get all of the records from the form you’ve assigned to your variable and loop through them to get the values you want.July 14, 2022 at 10:52 AM #47610
angParticipantHi Brendan,
Thank you for your answer.
I do not have sufficient bases to understand what I must do.
I ended up finding an alternative using “one to many” instead of “many to many”, I have the correct field showing up so its ok for me.thanks to you and Daniel
July 14, 2022 at 4:17 PM #47614
Daniel LeuParticipantI hope to have time to look at your form this weekend.
-
AuthorPosts
You must be logged in to reply to this topic.