cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dexter_Oz
Helper I
Helper I

FetchXML no results

I am testing my first fetchxml query. 

Steps Followed : 

1) Added Site settings > 1) Webapi/contact/enabled. 2) Webapi/contact/fields. ( * all fields) 3) Webapi/error/innererror.

2) Table permission for contact table 

3) Web Role > associated table permission > added user to web role

4) Below fetch query 

5) when add it to the web page no results or error 

 

 

Thanks in anticipation

 

{% fetchxml contactList %}
  <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname">
    <attribute name="emailaddress1">
    <attribute name="parentcustomerid">
    <attribute name="telephone1">
    <attribute name="statecode">
    <attribute name="contactid">
    <attribute name="firstname">
  </attribute></attribute></attribute></attribute></attribute></attribute></attribute></entity>
</fetch>
{% endfetchxml %}


<table id="tblData" class="table" style="border:1px solid">
        <thead class="thead-dark">
            <tr class="table-heading">
               
                <th>First Name</th>
                <th>Email</th>
                <th>Business Phone</th>
            </tr>
        </thead>
        <tbody>
        {% for result in contactList.results.entities %}
       {% assign contactids  = result.contactid %}
        <tr>
           
            <td><input type="text" id="txtfullName|{{result.contactid}}" contactid="{{result.contactid}}" value="{{ result.firstname }}" onchange="pushArray(this);"></td>
            <td>{{ result["emailaddress1"] }}</td>
            <td><input type="number" id="txtBusinessPhone|{{result.contactid}}" contactid="{{result.contactid}}" value="{{ result.telephone1 }}" pattern="\d*" title="Please enter Numbers only..." onchange="pushArray(this);"></td>
          
          
         </tr>
          <tr class="no-records" style="display: none;">
             <td colspan='6'>No Record Found</td>
         </tr>
        {% endfor %}
         
    </tbody>
</table>
</div>

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
eugenevanstaden
Resolver III
Resolver III

@Dexter_Oz 

I did a quick test on my side. Works all good with basic Table Permissions. Did you assign the Web role to the Table permission and the Web role to the logged in user?

 {% fetchxml testers %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
  </entity>
</fetch>
{% endfetchxml %}

              <select name="testers" id="testers">
                    {% for item in testers.results.entities -%}
                        <option value="{{item.id}}">{{item["fullname"]}}</option>
                    {%endfor%}
                </select>

 

 

View solution in original post

9 REPLIES 9
eugenevanstaden
Resolver III
Resolver III

@Dexter_Oz 

The Fetchxml looks a bit odd, can you fix this?

</attribute></attribute></attribute></attribute></attribute></attribute></attribute></entity>

 
Close each attribute

<attribute name='name'  />

Updated that and tried still no luck.

 

Also to double check i added the contact table through a list so it can fetch records on the same page , same user that works but not he fetchxml am i missing some other configuration. 

 

 

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="emailaddress1" />
    <attribute name="parentcustomerid" />
    <attribute name="telephone1" />
    <attribute name="statecode" />
    <attribute name="contactid" />
    <attribute name="firstname" />
  </entity>
</fetch>

 

 

eugenevanstaden
Resolver III
Resolver III

@Dexter_Oz 

What is your Table Permission set on the Contact table?



These settings only required if you are using the Portal Web API
1) Added Site settings > 1) Webapi/contact/enabled. 2) Webapi/contact/fields. ( * all fields)  Webapi/error/innererror.

Table permission is set to Global. 

 

My next step is to do CRUD operation on grid data so i was setting the Site Settings config. 

Fubar
Solution Sage
Solution Sage

use long notation to close out the tags, this is from the doco

When using fetchxml to query data, ensure you don't use self-closing tags. For example, instead of <attribute name="title"/>, use <attribute name="title"></attribute> with explicit closure tag </attribute>.

 

eugenevanstaden
Resolver III
Resolver III

@Fubar 

I always use the self closing approach with no problem. I expect his issue is the Entity Permission setup

I updated the query to check on explicit closure tag also but did not help 

 

Dexter_Oz_0-1662091399701.png

Table permission 

 

Dexter_Oz_1-1662091446151.png

 

eugenevanstaden
Resolver III
Resolver III

@Dexter_Oz 

I did a quick test on my side. Works all good with basic Table Permissions. Did you assign the Web role to the Table permission and the Web role to the logged in user?

 {% fetchxml testers %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
  </entity>
</fetch>
{% endfetchxml %}

              <select name="testers" id="testers">
                    {% for item in testers.results.entities -%}
                        <option value="{{item.id}}">{{item["fullname"]}}</option>
                    {%endfor%}
                </select>

 

 

Thanks really appreciate your help. i think it was something wrong in the table html which was there. I just took your example and build html around that and it worked. 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,287)