How to display automatically properties from an ItemType in a Form from another ItemType, thanks to an ID


I'm searching for a solution capable of displaying automatically properties from an ItemType in a Form from another ItemType, with an ID that creates a link between them.

I have an item linked to a form and I have a second item with some properties. I want to populate one field of the first form with the data of the second item. This field corresponds to a certain property of the first item.

To highlight my problem there is an example.

The first Item is called “student_info”. . The other properties don't matter for my problem.

  1. ItemType, Name = “student_info”

1) "student_name", DataType = "Text",

2) "student_class", DataType = "String",

3) "exam_1", DataType = "String"

4) "exam_2", DataType = "String"

5) “id”, DataType = "Item", Data Source = "student_info".

In my form “student_info”, I have a field where I want to display all the exams that a student has passed.

All the exams infos come from the second item. This ItemType is called "exam". It has 5 importants  properties :

  1. ItemType, Name = “exam”

1) "exam_name", DataType = "String",

2) "exam_descrption", DataType = "String",

3) "exam_discipline", DataType = "List", Data Source = "Discipline",

4) "exam_monitor", DataType = "List", Data Source = "Monitor",

5) “id”, DataType = "Item", Data Source = "exams".

I succeeded in changing the “id” with the “exam_name” thanks to another question on this forum !

Each student has passed a different exam. And each exam can be passed by a different student.

So, in my “student_info” form, I have created a HTML Field with an id included in a div. The id is linked to a method called “load_exam” that displays all the exams the student has passed.

BUT for the moment, I need to add manually via a Relationship that I create between the ItemType “student_info” and the ItemType “exam”. To add the exam I need to go in the edit view of the ItemType “student_info” and in the tab called “Add Exam”. And after in a dialog box I choose the right exam.

Now I want to find a solution that automatically displays the list of exams for each student. In fact if I fill the properties “exam_1” and “exam_2” with the exam name, that corresponds exactly to the “exam_name” property. I want to have the list of exams in the HTML Field of the “student_info” Form.

Thanks for reading, I hope you can understand my problem and help me to solve it !

P.S. : I can show my JavaScript code for the method “load_exam”, if you want.

  • Hi,

    I am not sure if this one is what you are looking for. But you can use a "Nested Form" to display content from one ItemType into the Form of another ItemType. Nested Form is one of the field types you can select in the Form editor.

  • Thanks Angelalp for you answer.

    But I already thought about nested forms and they don't match what I'm looking for ...

    More simply, I want to extract data from one or more Item from an ItemType (in my case, "exam") with the id of the Item I want. Then I want to display it in a HTML table in my "student_info" Form..

    The id is integrated in the form of "String" in my Form "student_info" but is not visible. Every "student_info" Forms have different "id" displayed as "String" so I should have as much data from "exam" in my table.

    I wish you can understand what I'm looking for.


  • Hi Harvey,

    ah okay. I still do not fully understand your use case, but I see that nested forms are not the right solution for you.

    As far as I understand, you are already able to display content in your html element. So your onLoad Method basically works? But why do you want to connect with ids?

    Do you have a property in your "Exam" ItemType that contains the linked student? You could than make a simple get query with a filter for the student name and render the table in the html with the onLoad method. 

    var exam = inn.newItem("Exam","get");
    exam .setProperty("student_name", "Kojak"); 
    exam .setAttribute("select","exam_name, result");
    exam = exam .apply();
    for (var i = 0; i < exam .getItemCount(); i++)
      // build table in html element