Automated Deployment: Adding a new field and migrating field data

By | November 16, 2018

 

Imagine this kind of (probably simplified) scenario:

  • You have added a field to the contact entity in the sandbox environment. Let’s say it’s “Saved Full Name” field
  • You have also created a workflow to copy values from the out-of-the-box “full name” field to your new custom field
  • You want to make sure that, once your updated solution is deployed in production, that new field is populated from the out of the box “Full Name” field as part of the deployment. The tricky part is that you might not be the one doing production deployment, yet the deployment itself may happen a few months later. Which means there will have to be some coordination.

 

This is where packaging your solution with EZ Change might be the way to go.

Here is how it works:

1. Create a new solution in Dynamics

Add Contact entity, new field, and the workflow to a new solution

image

When setting up the workflow, make sure it’s configured as an “on demand” workflow:

image

2. Create a package using EZ Change

For the introduction to EZ Change, have a look at the previous post: http://www.itaintboring.com/dynamics-crm/automated-deployment-and-dynamics/

This package won’t need any special build actions, and there will be two run-time actions. First, you would need to deploy the solution. And, then, you would need to run the workflow. So here is how the package will look like:

image

Deploy Solution Action does not require any special parameters. It will deploy the solution and publish customizations. The second action is where the data migration will be happening.

When defining that action, you’ll need to provide workflow ID and FetchXml so the tool knows which workflow to run and on which records:

image

3. Save the package and build it

Use File->Save to save the package

Use Package->Build to build the package

4. Add your package file name to the “orderedpackages.txt” file

This is how the tool will know which packages are supposed to be deployed when the time comes to deploy them

image

At this point everything will be ready for production deployment, and you will have two options to deploy in production:

5.a  Individual package deployment

You can start the tool, open the package, and run it to your environment using Package->Run menu

5.b  Cumulative deployment

You can run the tool from the command line:

ItAintBoring.EZChange.exe <Path to the packages folder> <Environment Name>

In which case the tool will deploy all packages mentioned in the orderedpackages.txt file which have not been deployed in the target environment yet (in other words, it’ll be a cumulative deployment).

In either case, as a result of this deployment you will achieve two goals:

  • A new field will be added to the contact entity
  • That field will be pre-populated from the out-of-the-box “full name” field:

 

image

Leave a Reply

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