ian.blair@softstuff

My technical musings

Create an identical Queue in another CRM system

Sometimes when you have multiple environments creating workflows or dialogs in your DEV system can prove to be an issue especially if queues are involved. Queues aren't included in solutions and if you create a queue with the same name in another system it will have a different Guid so when the workflow that references that is moved across to production it will break.

Its pretty straightforward to create a queue with the same Guid in another system and only requires a few lines of code.

First get the Guid of your queue.

Find the Guid in the settings -> business management -> queues screen and then press the pop-out button. (Highlighted here with an arrow).

Once you have this in the location bar of the new browser window you will see the string that contains the Guid for the queue.

"https://crm2016/testorg/main.aspx?etc=2020&extraqs=&histKey=885738149&id=%7b3D9CB3AB-C26B-E711-80FE-005056877901%7d&newWindow=true&pagetype=entityrecord#78522619

You will need the highlighted section, although the guid will of course be different on your system.

The using Visual Studio and the latest version of the Dynamics365 API you will need code like this.

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Tooling.Connector;
using System.ServiceModel;

var connectionString = "url=https://mycrmsystem; Username=myusername; Password=mypassword; authtype=Office365";
CrmServiceClient conn = new CrmServiceClient(connectionString);
using (OrganizationServiceProxy orgService = conn.OrganizationServiceProxy) {
     if (conn.IsReady) {
       
               Entity newq1 = new Entity("queue");
               newq1["queueid"] = new Guid(<the guid from above>);
               newq1["name"] = "<The name of the queue>";
               orgService.Create(newq1);‚Äč
      }
}

 

This can be wrapped in your favourite type of program, console app or windows form based program and when run will create a queue that you can reference in workflows and dialogs and won't get broken when they move across into production.