Search code examples
dynamics-crmliquidadxstudio-portals

Use Liquid to reference field through 1-N relationship in Dynamics portal web page?


I am working in Dynamics CRM Online with the customer self-service portal add-on and trying to use Liquid to go from the user object to the related external identity record(s) to get a field from those records. Looking at the Microsoft documentation here under the "attribute or relationship name" section it mentions that "You can also load any related entities by relationship schema name". So, for example, if I want to go from user to external identity and get the username field, I am trying this on a test web page:

{{ user.adx_contact_externalidentity.adx_username }}

where adx_contact_externalidentity is the name for the 1-N relationship. I am logged in so the user object is set, but I get nothing back from the code above. Is it possible to do this and I have the wrong Liquid syntax, or do I need to use the service page approach to query the external identity data and return it?

EDIT: I also tried {{ user.adx_contact_externalidentity.size }} since it is a 1-N relationship and I'm expecting adx_contact_externalidentity would be an array. The result of that is 1 so it is an array object and there's an item in the array. I then tried to access a field on the item with this:

{{ user.adx_contact_externalidentity[0].adx_username }}

but that didn't give me anything either.


Solution

  • I think you are heading in the right direction. On Adxstudio I've just confirmed this works:

    {{ user.adx_contact_externalidentity[0].adx_username }} .

    Try setting up entity permissions for the external identity record. This isnt required in Adxstudio, but I think it may be in Microsoft Portals.

    Also try using a loop to iterate over the contents.

    {% for child_page in page.children %}
    
    <a href="{{ child_page.url }}">{{ child_page.title }}</a>
    
    {% endfor %}