Tip #1236: Review RetrieveMultiple plugins before migrating to Unified Interface

It’s not uncommon to register a plugin on RetrieveMultiple message and fiddle with the output, e.g. drop some values, add some calculations, etc.

Chances are that you are changing the QueryExpression, and the plugin is working fine in the classic UI but you will have challenges migrating to Unified Interface.

The reason is that in the Unified Interface Dynamics 365 uses FetchExpression, so you’ll need to handle both cases if you want to use both classic UI and Unified Interface.

To reuse as much of the existing code as possible, use FetchExpressionToQueryExpressionRequest to convert, then do what you need to the QueryExpression, and then change it back with QueryExpressiontoFetchExpressionRequest. Sample code is available.

Thank you Guillaume Domont for the tip! (And don’t forget to send yours to jar@crmtipoftheday.com).

Cover photo by Lucas Vasques

9 thoughts on “Tip #1236: Review RetrieveMultiple plugins before migrating to Unified Interface

  1. Jonas Rapp says:

    Remember though that converting back and forth between FetchXML and QueryExpression impacts performance reasonably much, so going the extra mile to handle your query manipulation directly in the FetchXML is preferred.

  2. Sergii says:

    Hey Colleagues,

    I have an issue with MS for some time.
    And to be honest the question I have is the same – as an input I still have a query expression. As an output – collection.
    we use “Retrieve multiple” plugin as a data provider to call external service and fill in Virtual entity.
    MS Support can’t provide any explanations or documents.
    Can you please explain where this FetchExpression comes from and where it should be converted?
    (For the moment everything works fine except the fact that we can see only one line on the interface and the message 1-8 of N records. However, they can’t be reviewed)

    Thank you in advance.

    • Per Sørensen says:

      Hi,

      I’m facing similar problems, if I change the EntityCollection, it only shows the first one.

      Ever find any solution for this ?

    • Hi Sergii,

      not sure what the question is. For a long time classic web ui used QueryExpression to get the data (e.g. for grids).

      In Unified Interface, the OOB code uses FetchExpression instead. They are both derived from QueryBase so only minimal code changes are required to change consumption from one to another. Now, internally CRM/CDS uses fetchxml so, regardless which class is used, in the end of the day it all gets converted to fetchxml. That’s why FetchExpression is probably faster. In addition, fetch allows you to do things not supported by QueryExpression.

      Due to the changes in UI code, RetrieveMultiple plugins should expect to get either one (used to be just QueryExpression).

      HTH
      George

Leave a Reply

Your email address will not be published. Required fields are marked *