web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to use fetchxml in...
Power Pages
Unanswered

How to use fetchxml in portal and read option set and related entity atrributes?

(0) ShareShare
ReportReport
Posted on by

I have following fetch xml code:

 

{% fetchxml contacts %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="contact">
<attribute name="firstname" />
<attribute name="lastname" />
<attribute name="fax" />
<attribute name="address1_line1" />
<attribute name="address1_line2" />
<attribute name="address1_stateorprovince" />
<attribute name="address1_country" />
<attribute name="emailaddress1" />
<attribute name="gendercode" />
<attribute name="birthdate" />
<attribute name="donotsendmm" />
<attribute name="preferredcontactmethodcode" />
<attribute name="donotemail" />
<attribute name="followemail" />
<attribute name="donotbulkemail" />
<attribute name="donotphone" />
<attribute name="donotfax" />
<attribute name="donotpostalmail" />
<order attribute="fullname" descending="false" />
 
<link-entity name="account" from="primarycontactid" to="contactid" link-type="inner" alias="ab">
<attribute name="name" />
</link-entity>
<link-entity name="new_relatedentity" from="new_relatedentityid" to="new_isstest" link-type="inner" alias="ac">
<attribute name="new_name"/>
</link-entity>
</entity>
</fetch>
{% endfetchxml %}

{% assign contact= contacts.results.entities[0] %}
 
I want to show option set value and reference entity name like:
 
{{contact.preferredcontactmethodcode@OData.Community.Display.V1.FormattedValue}}  //nothing showing
{{contact.ab.name}} //nothing showing
{{contact.ac.new_name}} //nothing showing
 
but none of them work.
 
not sure my syntax is correct or not in portal template.
 
any advice?
Categories:
I have the same question (0)
  • Verified answer
    justinburch Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    Your syntax is a bit off and your related contact is not pulling in a valid contact value (I believe). Try the following:

    {% fetchxml contacts %}
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
    <entity name="contact">
    <attribute name="firstname" />
    <attribute name="lastname" />
    <attribute name="fax" />
    <attribute name="address1_line1" />
    <attribute name="address1_line2" />
    <attribute name="address1_stateorprovince" />
    <attribute name="address1_country" />
    <attribute name="emailaddress1" />
    <attribute name="gendercode" />
    <attribute name="birthdate" />
    <attribute name="donotsendmm" />
    <attribute name="preferredcontactmethodcode" />
    <attribute name="donotemail" />
    <attribute name="followemail" />
    <attribute name="donotbulkemail" />
    <attribute name="donotphone" />
    <attribute name="donotfax" />
    <attribute name="donotpostalmail" />
    <order attribute="fullname" descending="false" />
     
    <link-entity name="account" from="primarycontactid" to="contactid" link-type="inner" alias="ab">
    <attribute name="fullname" />
    </link-entity>
    <link-entity name="new_relatedentity" from="new_relatedentityid" to="new_isstest" link-type="inner" alias="ac">
    <attribute name="new_name"/>
    </link-entity>
    </entity>
    </fetch>
    {% endfetchxml %}
    
    {% if contacts.results.entities.size > 0 %}
    Contact with AB and AC found!
    {% assign contact = contacts.results.entities | first %}
    AB Name: {{ contact.ab.fullname }}
    AC Name: {{ contact.ac.new_name }}
    Preferred Method of Contact: {{ contact.preferredcontactmethodcode.label }} ({{ contact.preferredcontactmethodcode.value }})
    {% else %}
    No contacts found
    {% endif %}

    Note that it won't return any results if there is no contact with both AB and AC related records, and both entities need to have proper Entity Permissions setup.

     

  • Community Power Platform Member Profile Picture
    on at

    Hi Justin,

    Thanks a lot for your reply.

     

    I have implemented your suggested solution that works but value doesn't show for two options type field like {{contact.donotphone.label}}.

     

    what could be syntax to show two option field value like donotphone?

  • Community Power Platform Member Profile Picture
    on at

    I have resolved the issue. Two option works as boolean type. So it works fine. 

  • VyasVaishali Profile Picture
    16 on at

    Hi,

    You can read my blog on how you can access column(field) of different data type using FetchXML and liquid in PowerApps Portal.

     

    Part 1: https://vblogs.in/fetchxml-in-powerapps-portal/

    Part 2: https://vblogs.in/fetchxml-in-powerapps-portal-part-2/ 

     

    Thank You.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard