Adding field of a different model in a table which consist another model

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I want to show a field of a model say A in table of model B. is it possible?
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Hi Sayan, there are lots of options for this, depending on how A and B are connected (it just may not be editable).

If the models are connected via a lookup relationship, then you can go into through the BA lookup and choose what field you want to show:



Or, if model A is a child object, you can include it in the model via child relationships, and drag the child relationships field into your model as a template. (Instructions here.)
   

If the models aren't related at all, then just make sure the field you want from A is included in your model and insert a template into your Model B table and use merge syntax {{$Model.ModelA.data.0.FieldName}}.... although this may not really be what you're going for because it will display the same value on every row of the table.

OR you can use table drawers to display information from related objects and child objects and it will be completely editable.
(Edited)
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb
Got it.. But still facing issue like checkbox field form model A is  displaying unchecked while the it is checked in model B
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
What purpose is two models serving?  You can show one model in multple components.  Show one field from the same model in multiple places.  If you do this the fields will stay synched - change a field in one place and it will be updated in a second place.  

If you use two models, they will only stay in synch if you save and requery,  or if you use a model action that detects field change and passes the new value to the second model. 
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Hmmm... So if you check it in the Model B table, it doesn't update on Model A?  This should be updated when you click Save (if your Save button is saving Model B and Saving/Querying Model A - it is really easy to create one with the actions framework).
Photo of Sayan Choudhury

Sayan Choudhury

  • 172 Points 100 badge 2x thumb
so need to save changes in both the model and the query model for both of them?