In my post last week, I initially only dealt with the availability of the multi-table lookups and very superficially mentioned that I was happy about the fast availability of the XrmToolBox plugin. However, I did not go into the functions of the plugin in detail and how I currently use it. I’ll go into that in more detail below.

To be able to use the Polymorphic Lookup Creator Plugin you first must use the XrmToolBox. Both the plug-in and the toolbox were developed by the multi-year Dynamics 365 MVP Tanguy Touzard. You can find the official page of the XrmToolBox here. If you are already using the XrmToolBox, make sure that you have already installed the current version, as this is required for the plugin. (Status of the XrmToolBox when the blog post was published: v1.2021.6.51)

When the XrmToolBox and the Polymorphic Lookup Creator Plugin are installed, everything from this part is prepared. The only thing missing is the environment to try out the multi-table lookups.
Before we start creating a multi-table lookup, I recommend creating a new solution in the environment for this purpose and if you haven’t already done so, you should first create a publisher that you need for the solution.

After the solution has been created and you have hopefully already thought about which tables your multi-table lookup should include, I recommend that you either create these tables in your solution, if these are custom ones, or if you want to use existing ones, import them to your solution using the “Add existing” -> “Table” button.

For this example, I select the three default sales tables quote, order and invoice. From my point of view, it is important to avoid any unwanted dependencies afterwards, so I leave the option “Include all components” deactivated and only select the components that I really need. But more about this below.

After this preparation has been made, I switch back to the XrmToolBox, connect to the environment in which I created the solution and start the Polymorphic Lookup Creator Plugin.

When the Polymorphic Lookup Creator has started, there are a few configuration options available to me:

First, I select the solution I just created, in which my newly created multi-table lookup should also be created. In the second step, I should select the referencing entity, i.e. the table in which the new multi-table lookup is created and later published on the form. For this test I decided to use the account again. In the third step under attributes, you should only be able to select the option when using the plugin for the first time. However, this will change later in this post.

Under referenced entities I then select the tables that I want to use as the source for the lookup and that I have already added to the solution – quote, order, and invoice. In the fifth and last step, I assign the Lookup Display name of the lookup that will be used when creating the field. The schema name is automatically filled in and I can change it if I want. By using the solution and creating a publisher, the plugin accesses this information and uses the defined prefix to create the new field.

When everything has been prepared, the creation can be started using the “Create Polymorphic Lookup” button.

After successfully completing the creation of the multi-table lookup, we see the automatically added account table, and the newly created relationships to the three selected tables. In the other tables, we then find the newly created relationship to the account.

I test the new lookup by adding a form to the account table and dragging the newly created field onto the form and publish it.

The lookup is on the form and when I open it, as expected, the three inserted tables are displayed, which I can also use and either select existing data records or create new ones (using the new advanced lookup feature).

To have all sales tables complete, I still lack the opportunity. But I don’t have to repeat the steps to integrate this into the existing lookup. It is sufficient to switch to the XrmToolBox plugin, select my solution and the account table again and then this time select the existing lookup that I have just created under attributes.

Now I can either remove existing relationships by unchecking the checkbox under “Referenced Entities” – or, as in my case, add another relationship to a new table by ticking the specific checkbox. When selecting an existing lookup, the “Create Polymorphic Lookup” option is grayed out. Instead, I have the options Apply Changes or Delete.

In my case I choose “Apply Changes“. Tests show that the simultaneous addition of new relationships and the removal of existing ones in the same step is entirely possible and works reliably. First the new relationships are added and then the existing ones are removed.

When adding the opportunity to the multi-table lookup, I deliberately decided not to add the table to the solution first. If we now look at the solution, we see that the table was added automatically, but in contrast to the previously manually added tables, for which no existing attributes habe been added, in case of the opportunity table all columns, relationship, views and forms have been added to the solution – as it happens when selecting the Add all components option.

Please note take your time and add the tables to the solution first if you do not want to create dependencies.

Finally, the removal of a multi-table lookup. In the last post about this topic, I referred to the option to use the classic editor. In doing so, however, I had completely overseen the possibility that this can also be done very easily via the plugin itself and without an error.

However, before the lookup that has just been published and tested can be removed, all dependencies must of course be removed, i.e. in my example I must first remove the field from the form and publish it.

After executing the delete command in the plugin, the corresponding lookup on the account and all related relationships under account, invoice, opportunity, order and quote are removed.

No responses yet

Leave a Reply

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