Rendering field values from Linked Entities

Hi HH Community,

I have linked two entity types together in the Knowledge Graph. Example Entity Structure:

Entity 1:

  • Entity ID
  • Name
  • Linked Entity Field Custom Field

Entity 2:

  • Entity ID
  • Name
  • Custom Field ABC

Let’s pretend in this scenario Entity 2 is linked to Entity 1 via the Linked Entity custom field. In my Answers Card JS and Template file, I have successfully managed to render the Entity 1:Name, Entity 2:Name in the same Card (via the LinkedEntity field value).

My question is: it is possible to render any additional field which is part of the linked entity, i.e. in this example, the value from Custom Field ABC?

It seems that when an Entity is linked, the Entity ID and Entity Name values are accessible to reference and render - but not the additional fields of that linked entity (despite referencing syntax such as c_linkedEntityName.c_customFieldABC).

Am I missing something here or is it a case that currently the Name/Entity ID is what is permitted to access?

Many thanks

Sam

Hi @Sam_Davis - you are correct in that, with Answers, you currently can only access Entity ID and Entity Name through the Related Entity field type. Yext will soon be rolling out support for additional profile fields and custom fields from the related entity, so be on the lookout for that in an upcoming release.

Best,
Sam

1 Like

Perfect, thanks for confirming @Sam_Torres - looking forward to see this expand further in a future release,

Kind regards

Sam

1 Like

Regarding that, has it happened yet? If not, when is that expected to be live?

1 Like

Hi, any updates to this? Thank you!

Hi,

I am also wondering if I can show another field besides the name or the entity ID of a linked entity on a card. Is this possible today?

Thank you!
Dana

Hi all,

Yes searching on and/or rendering fields from related entities besides name and entityId is now possible with Multi-Hop Search!

By default in the API response, we return all data fields from the entity, plus the name and entityId of related entities for rendering purposes. However, you can decide what fields you want returned by using the displayFields property in the config, under each vertical.

So in @Sam_Davis 's first example, if I want to display Entity 1 name and Entity 2 name and custom field ABC, I would add the following to my config:

"verticals": {
    "[verticalKey]": {
        "displayFields": [
            "name",
            "c_linkedEntityName.name"
            "c_linkedEntityName.c_customFieldABC"
        ],
        ...
    },
    ...
}

Alex

1 Like

HI Alex,

Thank you so much! That’s helpful. So in order to render the multi-hop fields on a card I have to update the search config first? Then I will have those fields available to me to use on a card?

Thank you!
Dana

Hey Dana, yes that’s right! If you want to render any multi-hop fields that are not name or entityId, then you will need to add them (and all the other fields you want to display) to displayFields. Essentially with displayFields, you are customizing the entity profile fields that get returned in the API response.

Best,
Alex

Hi @Alex_Yang,

I’m following the steps to enable this in one of my experiences. In my Services vertical, I’d like to include the Name as well as the Keywords fields of the linked Location entities. FWIW, I’ve set these same fields as searchable fields in the Services vertical which is working as expected.

"services": {
      "entityTypes": [
        "ce_service"
      ],
      "displayFields": [
        "name",
        "c_serviceLocationLink.name",
        "c_serviceLocationLink.keywords"
      ],
      "name": "Services",
      "searchableFields": {
        "c_serviceLocationLink.keywords": {
          "nlpFilter": true
        },
        "c_serviceLocationLink.name": {
          "facet": true,
          "nlpFilter": true
        },
...

However, when I add the displayFields object to my config and specify any linked entity fields, the query request errors out. The request works as expected when I only include “native” (=zero hop) fields, e.g. name.

When I look at the response of the raw API call, the following error is flagged:

InternalApiResponse: statusCode: 400\nerror {\n code: 2272\n type: FATAL_ERROR\n message: \"Invalid fields parameter: c_serviceLocationLink.name\"\n}

Could you let me know what I’m doing wrong?

Thank you!
Max

Hi Alex,

I also tried this on my experience and when I try to do something like this:

linkedAssets: profile.c_linkedCampaignFromJunction.c_linkedCampaignOnJunction.name

I get an error like this:

When I comment out that line, the card renders properly. I’ve set up the displayFields properly as you described above. Am I setting the field wrong? Let me know what I should update!

Thank you!
Dana

Hi again Alex/community,

We realized by looking at the API response that the data is coming back in a list and I was trying to parse it as if it was an object. Instead, I needed to grab the value like this:

linkedAssets: profile.c_linkedCampaignFromJunction[0].c_linkedCampaignOnJunction[0].name

That worked and brought back the value I expected!

Thank you so much!
Dana