Animated GIF showing how to create records with the same IDs in Dynamics 365

Creating Records with the Same IDs in Dynamics 365: A Quick Tip

Creating Records with the Same IDs in Dynamics 365. If you’re working with Dynamics 365 in multiple environments, such as development, testing, and production, you may need to create records with the same IDs in each environment for testing and other purposes. Fortunately, it’s easy to do this using the code provided below.

Here’s how:

Step 1: Copy the code below into the web console in your browser.

// Create Customer Support Queue
let data =
{
    "name": "Customer Support"
}

// Create Queue record
Xrm.WebApi.createRecord("queue", data).then(
    function success(result) {
        console.log("Queue created with ID: " + result.id);
    },
    function (error) {
        console.log(error.message);
    }
);

Step 2: To create records with the same ID in Dynamics 365 across different environments, add the queueid property to the data object and include the first environment’s GUID value that was created. This works for any table record that you want to have the same ID, as shown in the example below.

// Create Customer Support Queue
let data =
{
    "queueid": "0d98deaf-ea7f-eb11-a812-0022489aea4e",
    "name": "Customer Support"
}

// Create Queue record
Xrm.WebApi.createRecord("queue", data).then(
    function success(result) {
        console.log("Queue created with ID: " + result.id);
    },
    function (error) {
        console.log(error.message);
    }
);

Step 3: Run the code in each environment.

Step 4: That’s it! You can now create records with the same IDs in each environment using the code you provided. Keep in mind that you’ll need to repeat this process for each record type you want to create with the same IDs.

I hope this quick tip helps you create records with the same IDs in Dynamics 365!

Take your IT project management and business process improvement skills to the next level with The Phoenix Project by Gene Kim, Kevin Behr, and George Spafford. This insightful book follows an IT manager’s journey toward improving his organization’s IT department, showcasing the key elements of successful IT projects, such as collaboration, communication, and automation. If you’re looking to improve your skills and drive successful projects, then The Phoenix Project is a must-read. It’s a valuable resource that provides practical insights, and it’s available now on Amazon and Audible.


For More Content See the Latest Posts