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