XrmToolbox Portal Records Mover as a Console Application

The Portal Records Mover is an excellent XrmToolbox plugin by Tanguy Touzard for anyone working on a Dynamics 365 Portals project.  If have not used this tool as part of your Portals deployment process, I suggest checking it out here: MscrmTools.PortalRecordsMover

Deploying Portals Configuration

With a Portals project comes the need to migrate your portal specific records to downstream environments, such as test, staging, and production.  For example, if you are using Web Forms, you might need to move the records for Web Site, Web Form, Web Form Steps, and any related Web Form Metadata, Web Templates, and Entity Forms.  Even with a simple Portals project, this quickly becomes a major undertaking just to ensure that environments update correctly.

The Portal Records Mover tool provides some excellent help in managing your records.  The tool is aware of the Portals solution Entity structure and provides the ability to export Portal specific records for re-import into another environment.

Portal Records Mover Main

Usage is pretty straightforward: the plugin provides a list of the Portals specific records, such as Entity Form, Entity List, Web Form, Web Form Step, etc.  You provide a date filter for the records you would like to retrieve, such as records modified on or after a specific date.  Once the records are retrieved, you can download the to an Xml file for re-import into a different Portal.

The cool bit about this tool is that under the hood, it uses the UpsertRequest when importing the data into the target system. Here is the documentation on using Upsert: Use Upsert to insert or update a record.  Why does this matter?  Using the UpsertRequest, the SDK call will first check to see if the record exists.  If it does not, the call will create the record.  If it does exist, the record will simply be updated. When you are deploying Portal updates to downstream systems, this saves a LOT of hassle in avoiding unnecessary duplicates.


We had been using the tool for a while on my current Portals project, but we starting moving to automated build and deployment. This meant the need to automate the Portal Records Mover form a command line. I asked Tanguy if he would permit my porting his code to a console application, and luckily he gave the thumbs up!  I cloned a copy of the Portal Records Mover plugin repository and began removing the UI elements, wrapping them with a console app.  My goal was to provide a console app with command line parameters that closely mimic the Portal Record Mover options, with the rest of the application remaining the same. Simply put, I wanted to keep the brains of the tool Tanguy built and just automate its execution.

Luckily, the plugin code is well organized and segmented such that I was able to preserve all of his business logic almost as is and wrap the calls in my console app. As stated, the new console application includes parameters that mimic the user interface options closely. I provide details on the command line options and and some example configurations with the code posted on GitHub. With the new console version of the Portal Records Mover, you can easily integrate this into your automated build and deployment process.

Some minor differences

I am providing usage notes on the Portal Records Mover Console in the GitHub repository, but I want to point out a few differences. Other than these deltas, the console application operates much like the XrmToolbox Portal Records Mover.

Date filters

I added an option around the date filters. In the console application, you can specify the created on or modified on filters as with the XrmToolbox plugin, or you can provide a number of days as a filter. For example, retrieve the records modified in the last 10 days. This aligns with our intent to periodically run builds where you want to choose only records that have changed since the last run. So if we ran nightly builds, I can retrieve all records modified in the last 1 day.

Immediate Import

An additional change is that you can export the records and immediately execute an import into a target environment.  In the XrmToolbox plugin, you can export the records to an XML file based on your current selection.  But to import into another environment, you have one additional step to change your connection. This is a minor bit of additional work, but because we are automating the process, we can import the retrieved records into a target environment in one run of the tool.

All files exported

The XrmToolbox plugin version will present the user with the list of records returned for each type for the selected Entities and date filters.  In the tabs for each Entity, the user has the option to check only those records they wish to be exported.  This is a really cool feature, but unfortunately we do not have the ability for this kind of selection with a console application.  I am looking into some options for additional filters for each selected Entity that may provide a bit more flexibility when exporting your records.

Saved Settings

This one is actually more of a similarity to the XrmToolbox plugin.  In the plugin, you have the option to save and load your current settings.  The command line options can be provided directly, or you can refer to a static XML configuration file that contains your parameters.  I like this as an option for dealing with multiple environments and my configuration XML is modeled after the saved values provided by the XrmToolbox plugin.

Take it for a spin!

You can download the code from the repository here: https://github.com/jamesnovak/PortalRecordsMoverConsole.  Check out the README.md for the command line options and general usage. I will provide more details as I continue working on the updates, such as Entity level filter options mentioned above.

Thanks to Tanguy for allowing me to leverage his existing work which has saved our project an enormous amount of time. I plan on keeping a close eye on the Portal Records Mover XrmToolbox plugin so I can keep things up to date with new features or fixes.

As always, comments, corrections, and suggestions are always welcome.  In this case, reporting any issues is definitely helpful.  Please let me know if you have any issues building the project, executing the app, or if you have suggested improvements.

0 Points

5 thoughts on “XrmToolbox Portal Records Mover as a Console Application”

  1. Hany Greiss says:

    I download and tried building the command line version of the tool on Visual Studio 2015. I got a number of errors on property get/set etc. Is Was this targeted for a specific version of VS?

    1. Jim Novak says:

      Hi Hany

      I would have to see the specific errors but my guess is that those are due to new C# v7 syntax options, not necessarily a version of Visual Studio.

      I believe that you can install C# v7 with VS 2015. If you have issues with that option, let me know and I can update the project to compile with VS 2015. Thanks!


  2. Rakshit Rastogi says:

    Hi Jim,
    We are not able to get inactive records and their N:N relationship records while running it as a console application. Whereas Portal Records Mover XRM application takes well care of it as it imports the records in multiple passes. Even if I set ActiveItemsOnly as False then also it is not importing inactive records.
    Have you ever faced such scenario. Any help would be appreciated

    1. Jim Novak says:

      Hi Rakshit
      I have a version that I am working which should incorporate recent updates made by Tanguy and the XrmToolBox version. I will test the situation you mentioned and will get back to you!

      1. Rakshit Rastogi says:

        Thanks for the Prompt reply Jim.
        I appreciate your efforts for looking into this and making this tool able to be used in CI/CD pipelines. This is the only place where we have a scope for automation in our project.
        I am anticipating a positive response from you on this.
        Thanks again for all your help.

Leave a Reply

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