Hi team, I’ve seen some related posts but wanted to ask: how can I show the name of a linked entity on my Answers card?
Right now I’m using the field itself, but am getting an [object object] error on the front end which is expected, I just don’t know what the correct formatting is to pull the Name. Please let me know, thank you!
1 Like
Hi Hannah,
Great question. The issue here is that a linked entity field is an array field – it can have multiple linked entities (not just one) so the subtitle field is unclear when you use c_linkedEntity.name
which name it should be pulling through (i.e., the name of the first linked entity, or the second or the third etc). In order to indicate to use the first Linked Entity, you have to add an index to the field. This will look something like this:
subtitle: profile.c_linkedDealerships ? profile.c_linkedDealerships[0].name : null,
Feel free to play around with this if you want to add more entities and be sure to QA all the cards.
Also, take a look at Access an Array item using the index position to learn more more about Arrays. You may notice the Photo Gallery field is set up this way under dataForRender in your card.
Best,
Alyssa
3 Likes
Thanks @Alyssa_Hubbard ! That worked perfect!
1 Like
So great to know! I was running into the same issue today and this post solved it immediately.