Move queue item from one queue to another programmatically in Dynamics 365

This article shows how to add a record from one queue to another.

AddToQueueRequest routeRequest = new AddToQueueRequest
{
        SourceQueueId = queueId.Id,
Target = new EntityReference(obj.LogicalName, obj.Id),
DestinationQueueId = userQueueId

};
orgService.Execute(routeRequest);

Sample Code

using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Crm.Sdk.Messages;
using System.ServiceModel.Description;
using System.Net;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Metadata.Query;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;

namespace CRMCodeHelper
{
class Program
{
private static IOrganizationService service = null;

static void Main(string[] args)
{

service = ConnectToCRM();

Guid sourceQueueId = new Guid(\"9b2296-bacb-e811-a962-000d3ab4998c\");

Guid destinationQueueId = new Guid(\"4f7cd6-54c5-e811-a95d-000d3ab49476\");

EntityReference Target =
new EntityReference(\"phonecall\",new Guid(\"8d408d-c255-4587-9e34-596d496e6738\"));

MoveQueueItem(sourceQueueId, destinationQueueId, Target);

}

public static
IOrganizationService ConnectToCRM()
{

IOrganizationService organizationService = null;
try
{

ClientCredentials clientCredentials = new ClientCredentials();

clientCredentials.UserName.UserName =
\"\";

clientCredentials.UserName.Password = \"\";

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

organizationService =
new OrganizationServiceProxy(new Uri(\"\"), null, clientCredentials, null);

return organizationService;

}

catch (
Exception ex)
{

Console.WriteLine(\"Exception caught - \" + ex.Message);

return organizationService;

}

}

public static void MoveQueueItem(Guid SourceQueueGuId, Guid DestinationQueueGuid, EntityReference ItemToMove)
{

AddToQueueRequest routeRequest = new AddToQueueRequest
{

SourceQueueId = SourceQueueGuId,

Target = ItemToMove,

DestinationQueueId = DestinationQueueGuid

};

service.Execute(routeRequest);

}
}

}

Published by arpitpowerguide

My name is Arpit Shrivastava, who is a Microsoft MVP in the Business Applications category. I am a Microsoft Dynamics 365 and Power Platform enthusiast person who is having a passion for researching and learning new things and acquiring immense knowledge. I am providing consistent help, support, and sharing my knowledge through various Social Media Channels along with my Personal Blog, Microsoft Community, conducting online training and attending various 365 Saturday Events worldwide and sharing the best Solutions to the readers helping them achieve their goals and objectives in Customer Relationship Space.

6 thoughts on “Move queue item from one queue to another programmatically in Dynamics 365

  1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents. IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. corporate training in chennai corporate training in chennai corporate training companies in india corporate training companies in india corporate training companies in chennai corporate training companies in chennai I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai Project Centers in Chennai

    Like

  2. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time. Contact him now and thank me later.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: