Thursday, January 3, 2019

Copying Records with GUID in Microsoft Dynamics 365

If you are using workflows it is likely that you need to link to specific records in the environment. One issue with this occurs if the record is manually created in each environment so when migrating workflows via solutions you still need to manually edit the workflow and re-link to the correct record. This is because the record GUIDs are not consistent across the environments.

But there is a solution!

I was working on this very issue today and had to re-learn how to handle so I want to document it for myself and hopefully it will be beneficial for you too. 

In my case we are using a Queue to send an email from a shared inbox via a workflow. So what I can do is create the Queue in our Development environment and then use an Import to create in other environments with the same GUID.

Steps: 


  1. Create Queue in Development environment.. Populate with all necessary details such as name, email address, etc.
    Create Queue record in Development environment
  2. Create an Advanced Find of these Queue Details. You will want to include any fields you populated such as the email address and description.
    Advanced Find to isolate new Queue details
    Export fields from Advanced Find to get GUID and ensure data matches
  3. Export the details from this Advanced Find. This will include the GUID of the record.
  4. Open this file and expose columns A, B, C.
  5. You can delete columns B and C. Then rename A to "GUID" for clarity. Save this file as a .csv
  6. In your next environment, click on Import Data and select the file you just saved.
  7. For Mapping, select the entity you want to import to (in this case, Queue) and then map any fields that are needed.
    • Map your "GUID" field to "Queue (Primary Key)"
    • Keep in mind some fields are set by the system so they may not let you map them. These can be ignored.
    • When importing map the "GUID" column to the Primary Key for the entity
  8. You can choose to save this map if you like for future environments. Then click "Submit"
  9. When the import is done, verify the new record was created and you can check the GUID. All should match.

If you entered a name for your Data Map (last step of import process), then you should follow these steps before moving to the next environment:

  • Settings -> Data Management -> Data Maps
  • Select the one you created and click "Export"
  • In your next environment, navigate to the same area and click "Import"

In your next environment you will use the existing file (from your Development environment) from step 5, no need to export again. For step 7, you can either remap or select the imported data map name.

I hope this is helpful for you! Have you had this issue in your organization? How do you handle?