Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - General Discussions
Unanswered

Fetchxml query not returning data when executed in portal page

(0) ShareShare
ReportReport
Posted on by 73

Hi community

 

I have the following fetchxml query which works fine when executed from FetchXml Tester and FetchXML Builder in XrmToolBox.

It returns details of associated documents held in SharePoint as expected.

 

paulinolan_0-1712848754422.png

 

However if I try and excute the query from within a portal page no data is returned. I suspect this is permissions related.

I have created a table permission for the sharepointdocument entity with access type Account and account relationship Account_SharepointDocument. There are no web roles associated with it.

Sharepoint Integration is on.

 

What am I missing?

 

Thanks

Categories:
  • Fubar Profile Picture
    8,023 Super User 2025 Season 1 on at
    Re: Fetchxml query not returning data when executed in portal page

    The query runs at the fetchxml tag.

    Isolate which tag is throwing the error - Put some text/html before each Liquid tag, the last bit of text you see on the web page will then be just before the Liquid tag that is failing.

  • PN-28081327-0 Profile Picture
    73 on at
    Re: Fetchxml query not returning data when executed in portal page
     
    I've run the fetchxml in the XrmToolBox tool FetchXml Tester and built the query in FetchXML Builder and it works okay. I've tried with valid values for new_agreementid which work
     
    I think the initial syntax error is referring to the Liquid error statement. The actual error is the Liquid error "Exception has been thrown by the target of an invocation"
     
    When running the query in the page I've purposely changed the entity name sharepointdocument to xsharepointdocument to force the query to fail and return no data. 
    In this case the liquid code 
     
            {% assign results = sharepointdocuments.results.entities %}
            {% assign count = results.size %}
     
    console.log("count " + '{{ count }}');
     
    writes "count 0" to the console as expected.
     
     
    However with the correct entity name in the query in the page the line
     
            {% assign results = sharepointdocuments.results.entities %}
     
    gives the error 
     
    "Liquid error: Exception has been thrown by the target of an invocation."
     
    Am I correct in thinking that the query is actually executed by this line?
     
    I'm wondering is the error related to the sharepointdocument entity supporting only associated view
  • Fubar Profile Picture
    8,023 Super User 2025 Season 1 on at
    Re: Fetchxml query not returning data when executed in portal page

    It is saying somewhere on that page you have syntax error.  Isolate if it is the fetchxml statement or not (also take the fetchxml and put it into fetchxml builder or tester in XrmToolBox and confirm it is correct), also look at the value(s) you are substituting in to the fetchxml 

  • PN-28081327-0 Profile Picture
    73 on at
    Re: Fetchxml query not returning data when executed in portal page

    Hi @Fubar

    It is the name of the test page where we are running the fetchxml. The output of the query will be used to populate a kendo grid

  • Fubar Profile Picture
    8,023 Super User 2025 Season 1 on at
    Re: Fetchxml query not returning data when executed in portal page

    No idea - where does the 'kendo' in the error come from?

     

     

  • PN-28081327-0 Profile Picture
    73 on at
    Re: Fetchxml query not returning data when executed in portal page

    Hi Fubar

    Thanks for the reply, apologies for the delay in replying.

    I have created the table permissions as suggested. However when I try and access the result entities returned by the query I get this error in the browser console -

    Uncaught SyntaxError: Unexpected identifier 'error' (at testcontractdocumentskendo/:1346;16)


    When viewed in the Sources tab the error is -

    "Liquid error: Exception has been thrown by the target of an invocation."

     

    The query and the liquid code which follows the query is as follows

    The error is thrown by the liquid code where I'm attempting to retrieve the results returned by the query

     

    {% fetchxml sharepointdocuments %}
    <fetch>
    <entity name="sharepointdocument">
    <attribute name="documentid" />
    <attribute name="fullname" />
    <attribute name="absoluteurl" />
    <attribute name="relativelocation" />
    <attribute name="sharepointcreatedon" />
    <attribute name="filetype" />
    <attribute name="modified" />
    <attribute name="sharepointmodifiedby" />
    <attribute name="title" />
    <attribute name="readurl" />
    <attribute name="editurl" />
    <attribute name="author" />
    <attribute name="sharepointdocumentid" />
    <attribute name="ischeckedout" />
    <attribute name="locationid" />
    <attribute name="iconclassname" />
    <order attribute="relativelocation" descending="false" />
    <link-entity name="new_agreement" from="new_agreementid" to="regardingobjectid" link-type="inner" alias="ad">
    <filter type="and">
    <condition attribute="new_agreementid" operator="eq" value="<some agreement id>" />
    </filter>
    </link-entity>
    </entity>
    </fetch>
    {% endfetchxml %}

    {% assign results = sharepointdocuments.results.entities %}


    I based my query on the following

    https://mscrm16tech.com/2020/09/09/get-sharepoint-document-details-for-particular-record-in-ms-crm-using-fetchxml/


    Do you have any suggestions what the target is that the error is referring to?

    Is it possible to get more details about a liquid error?

    Thank you

  • Fubar Profile Picture
    8,023 Super User 2025 Season 1 on at
    Re: Fetchxml query not returning data when executed in portal page

    Not "Self", self is only for the Portal User to be able to access their own Contact record (e.g. update their details on the Profile Page).

     

    In what I was describing, you would use Scope = Parent on the sharepoint table permission, and then choose the relationship/table permission for the the link table (your agreement table).

  • PN-28081327-0 Profile Picture
    73 on at
    Re: Fetchxml query not returning data when executed in portal page

    Okay, that didn't work. My page threw the error 

     

    Liquid error: Entity Permission SharePointDocumentRead c2c46ddc-8bf5-ee11-a1fd-000d3a210e73 Scope value Self is not applicable to entity sharepointdocument.

     

    I've set 

    Access Type - Account

    Account Relationship - Account_SharePointDocument

     

    and now I get 

    Liquid error: Exception has been thrown by the target of an invocation

     

    What is throwing the error is this liquid which is executed after the fetchxml

     

    {% assign contractdocumentsentities = contractdocuments.results.entities %}
  • PN-28081327-0 Profile Picture
    73 on at
    Re: Fetchxml query not returning data when executed in portal page

    Hi @Fubar

    Thanks for the reply.

    When you say ...

    'Unless there was a specific requirement to put an Account Lookup on the sharepointdocument table, I would probably do a Table permission on new_agreement (that is Account assuming it has a lookup to Account that is being populated), and then a Child permission (i.e. Scope = Parent) between new_agreement and sharepointdocument.'

    ... what would the Access Type for sharepointdocument be, I've set it to Self

    My permissions now look like

    paulinolan_0-1712930534730.png

     

    paulinolan_1-1712930591139.png

     

    Web roles have been applied to both

     

     

    Thanks

  • Fubar Profile Picture
    8,023 Super User 2025 Season 1 on at
    Re: Fetchxml query not returning data when executed in portal page

    For a Table Permission to work it must be associated with a Web Role that is being used by the Portal User.

     

    Account scope on a Table permission means that you have a Lookup on the Table in question to Account and the portal user's parent account (using the out of the box relationship/lookup) is the account populated in the Lookup.

     

    Note: you would need a Table permission for both of the Tables in the query.

     

    Unless there was a specific requirement to put an Account Lookup on the sharepointdocument table, I would probably do a Table permission on new_agreement (that is Account assuming it has a lookup to Account that is being populated), and then a Child permission (i.e. Scope = Parent) between new_agreement and sharepointdocument.

    Child (scope parent) means you do not need a lookup on the other table e.g. if you had an Invoice and Invoice Line Items, you wouldn't put an Account lookup on each line item just on the Invoice, and you would then use a Child Table Permission between Invoice and Invoice Line Item).

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35