D365 Portals – application/xml

I keep forgetting how to do this and can’t remember where I saw it written down so I am writing this down now. If you need to check the fetchXML that is being called as part of a Web Template then you can return that fetchXML in a Web Page. This can be useful where you have fetchXML that is generated dynamically based on request parameters or if you just want to check the values that are included in your fetchXML from the request.params collection.

  1. Create the Web Template with your fetchXML query
  2. After the {% endfetchxml %} line, display the content of you fetchXML query using the XML property of your fetchXML object.
  3. Set the MIME Type of the Web Template to application/json
  4. Create a Page Template for your Web Template, with no headers or footers.
  5. Create a Page using the Page Template so you can get the XML content

For example, my Web Template would look like this

{% fetchxml assetQuery %}
<fetch version='1.0' output-format='xml-platform' mapping='logical' page='1' count='200'>
  <entity name='msdyn_customerasset' >
    <attribute name='msdyn_customerassetid' />
    <attribute name='msdyn_account' />
    <attribute name='msdyn_parentasset' />
    <attribute name='msdyn_name' />
{% endfetchxml %}

{{ assetQuery.xml }}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s