Dynamics 365 Integration

The easiest way to connect Dynamics 365 and Dynamics CRM with WordPress.


A view is a grid with records listed under selected column headings. It is a type of saved query. Users can select different views to look at a subset of records of the same entity that fit into pre-specified filter conditions. There are 3 main types of views: public, system, and personal.

You can insert views from Dynamics CRM into your posts and pages using shortcode [msdyncrm_view].

Shortcode syntax:

[msdyncrm_view entity="invoice" name="Show Invoices" parameters="{querystring.id}" lookups="{contact:}" allfields="true"]

The output of this shortcode is a table populated with record columns retrieved from Dynamics CRM based on view settings.

Shortcode attributes

Required String Name of the view (saved query) to display records, e.g. Active Invoices.
Required String Logical name of the entity that contains the view, e.g. invoice.
String See Parameters
String See Lookups
Integer Records per page. Enables pagination if value is larger than zero.


Allows to substitute {n} ({0}, {1}, etc.) placeholders with values. Example:



Allows to customize lookup conditions. Example:


Inline views

Dynamics CRM Integration Premium allows to define views that do not rely on view definitions in the CRM. The basic view consists of a view shortcode with attributes, but a view for the inline templates can be defined inside the msdyncrm_view tag, i. e. [msdyncrm_view]...[/msdyncrm_view].

The inline templates for views allow to:

  1. Specify custom FetchXML to retrieve entity records from Dynamics CRM with placeholder parameters like currentuser, currentrecord, and querystring.
  2. Create layouts for results that support HTML markup, foreach loops and formatted fields.
  3. Print a custom template if no records have been retrieved.

Creating inline templates

Generate a FetchXML via Dynamics CRM Advanced Find tool, or create one yourself and insert it into the [msdyncrm_view] shortcode.

Define a FetchXML

See also: FetchXML documentation at MSDN.

In this example, we’re retrieving ten Contact records, fetching only fields contactid, fullname, emailaddress1, and mobilephone, using fullname for ascending order.

Define a results template

Add the results node into the [msdyncrm_view] shortcode. <results /> may contain HTML tags. Please note that its contents must be valid XML.

    <h2>Contacts list</h2>
    <p>List of active contacts</p>

To show retrieved records, tags <foreachrow /> and <foreachcell /> are introduced.

<foreachrow /> loops through the collection of retrieved records. If you retrieve ten records, the template contained in this tag will be rendered ten times – once for each record. To access record fields, use the $row.fieldname syntax inside <foreachrow />. For instance, $row.emailaddress1 will print the value of emailaddress1 field of the current record.

To print out all available record fields straight away, use <foreachcell /> inside the <foreachrow /> tag. Formatted field value can be accessed using the $cell construct.

Define an empty results template

If no records were retrieved from the CRM, you can display a custom message using <noresults />.

    <p>Sorry, no contact records found.</p>

Assemble all pieces together

Below is the resulting code for the inline view template including the shortcode opening and closing tags.

Using inline templates with CRM views

<results /> and <noresults /> templates may be used with CRM views.

Using lookups and parameters in FetchXML