Forum Discussion

vinay_iTalent's avatar
vinay_iTalent
Community Manager
3 months ago

Not able to assign a separate field to atomic-result-link component

Hi Team,

In the Coveo JSUI framework, we have the capability to customize the default behavior of result links by assigning specific data fields using the attribute data-field="@uri" to the class CoveoResultLink. This allows us to map the desired input to the specified field, thus enabling customization of result links according to our requirements. But how can we use the same in atomic-result-link.

Do you have any suggestions or workarounds to address the use cases mentioned above?

  • prem_iTalent's avatar
    prem_iTalent
    Community Manager

    Hi vinay_iTalent

    By default, coveo-atomic does not provide these options. You need to create a custom component as below.

    Defines a method to render the content of the custom element and Retrieve the value of the "SpecificField" property from the search result data.

    Ex Code Snippet:

    const name = this.result.result.raw["SpecificField];

    this.shadow.innerHTML = "by <a href=" + Name + " target='_blank'  + Name + "</b></a> in <a href=" + Name + " target='_blank' + Name + "</b></a>

    Constructs an HTML string representing the content to be displayed in the shadow DOM. It includes hyperlinks for the Fields, along with their respective labels as per the requirement.

    Coveo Reference Document Link: https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/