In Dynamics CRM 2011 we can
manually assign the entity records to Queue from the Entity Form or List View
(Grid) ribbon Add to Queue button
but to assign the items automatically to queue either we can create a Queue
Item record (discussed
in this post) or may use AddToQueue request.
Case Priority Equals High
[C# Code Example]
[JScript Code Function Call Example]
[Plugin Usage Example]
The following examples
below can be use to add an entity record to the Queue via a process Workflow,
Jscript, C# code and also explains how to use plugin code for AddToQueue plugin
message.
[Workflow Process
Example]
The following steps below describe the solution
for adding a High Priority cases to the High Priority Cases Queue using
AddToRequest by using workflow custom activity.
1. Import WodCrmWorkflowLibrary_1_0_managed.Zip
solution in CRM, you can download solution from this link: https://skydrive.live.com/redir.aspx?cid=06f61fc8aa6032c9&resid=6F61FC8AA6032C9!152&parid=6F61FC8AA6032C9!117
2. Create new workflow process, go to Settings → Process
Center → Processes, click on new button and enter process details:
·
Enter
Processname i.e. Assign Cases to
Queue,
·
In
Entity field choose Case
·
In
Category field choose Workflow and click ok button
3. In workflow Options for
Automatic Process choose the following:
·
In
Scope choose Organization
(If require to run this workflow
for all Case records regardless of Business Units or User specific records)
·
In
Starts When check Record is Created option
4.
Add Check Condition step, click on the
condition and In Specify Condition Web
Dialog, choose Case (entity) in first list box, choose Priority (case entity field) from
second list box, choose Equals
(condition operator) in list box and
choose High (case priority field
value) in the final list box. The condition will look like:
Case Priority Equals High
5.
Add
wod.Crm.Workflow.Library.v1 → QueuesLibrary.wod_AddToQueueRequest
step and click on Set properties button and set the following properties:
·
In Source Queue
field, choose queue from which the record is required to be move (optional
paramter)
·
In Destination Queue
field, choose queue record i.e. High Priority Queue
·
If you will mention
the entity name in Entity Name field (optional paramter) then you have to also pass
the Entity GUID into the Entity GUID field, if these fields will leave blank
then workflow actvity will automatically take up current entity and its GUID
6.
Click on Activate button to Activate the process
[C# Code Example]
private void Main(IOrganizationService wod_CrmService)
|
{
|
// Assigning CRM
Queue GUID value, the entity record will be added to this queue
|
// SourceQueueId parameter is optional and may skip
|
Guid wod_SourceQueueId = new Guid("D8FACAB8-6B8F-E111-A6A1-B8AC6F3EDD32");
|
// Assigning CRM Queue GUID value, the entity record
will be added to this queue
|
Guid wod_DestinationQueueId = new Guid("10AD0882-9F96-E111-A6A1-B8AC6F3EDD32");
|
// Assigning entity name & id, this entity
record will be added to the queue
|
EntityReference wod_CaseLookup = new EntityReference()
|
{
|
LogicalName = "incident",
|
Id = new Guid("EE0CB48D-A28F-E111-A6A1-B8AC6F3EDD32")
|
};
|
// Creating AddToQueueRequest and assigning require parameter
values to it
|
// AddToQueueRequest object will be passed to the
CRM service execute method
|
AddToQueueRequest wod_AddtoQueueRequest = new AddToQueueRequest
|
{
|
// Only pass Source Queue Id
parameter (optional) value in case of moving item from
|
// older queue to new queue
|
SourceQueueId =
wod_SourceQueueId,
|
DestinationQueueId =
wod_DestinationQueueId,
|
Target = wod_CaseLookup
|
};
|
// Passing AddToQueueRequest object to CRM Service
Execute method
|
// for request processing
|
AddToQueueResponse wod_AddToQueueResponse =
(AddToQueueResponse)wod_CrmService.Execute(wod_AddtoQueueRequest);
|
[JScript Code Example]
if (typeof
(wod_SDK) == "undefined")
|
{
wod_SDK = { __namespace: true }; }
|
//This will establish a
more unique namespace for functions in this library. This will reduce the
|
// potential for
functions to be overwritten due to a duplicate name when the library is
loaded.
|
wod_SDK.QueuesLib
= {
|
_getServerUrl: function () {
|
///<summary>
|
/// Returns the URL for the SOAP endpoint using
the context information available in the form
|
/// or HTML Web resource.
|
///</summary>
|
var ServicePath = "/XRMServices/2011/Organization.svc/web";
|
var serverUrl = "";
|
if (typeof GetGlobalContext == "function") {
|
var context = GetGlobalContext();
|
serverUrl =
context.getServerUrl();
|
}
|
else {
|
if (typeof Xrm.Page.context == "object") {
|
serverUrl =
Xrm.Page.context.getServerUrl();
|
}
|
else
|
{ throw new Error("Unable to access the server URL"); }
|
}
|
if (serverUrl.match(/\/$/)) {
|
serverUrl =
serverUrl.substring(0, serverUrl.length - 1);
|
}
|
return serverUrl + ServicePath;
|
},
|
AddToQueueRequest: function
(prmSourceQueueId, prmDestinationQueueId, prmEntityName, prmEntityId) {
|
var wod_Request = ""
|
wod_Request += "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
|
wod_Request += " <s:Body>";
|
wod_Request += " <Execute
xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\"
xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
|
wod_Request += " <request
i:type=\"b:AddToQueueRequest\"
xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"
xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
|
wod_Request += " <a:Parameters
xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
|
wod_Request += "
<a:KeyValuePairOfstringanyType>";
|
wod_Request += "
<c:key>Target</c:key>";
|
wod_Request += " <c:value
i:type=\"a:EntityReference\">";
|
wod_Request += " <a:Id>" +
prmEntityId + "</a:Id>";
|
wod_Request += " <a:LogicalName>" +
prmEntityName + "</a:LogicalName>";
|
wod_Request += " <a:Name i:nil=\"true\"
/>";
|
wod_Request += " </c:value>";
|
wod_Request += "
</a:KeyValuePairOfstringanyType>";
|
wod_Request += "
<a:KeyValuePairOfstringanyType>";
|
wod_Request += " <c:key>DestinationQueueId</c:key>";
|
wod_Request += " <c:value
i:type=\"d:guid\"
xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" +
prmDestinationQueueId + "</c:value>";
|
wod_Request += " </a:KeyValuePairOfstringanyType>";
|
if (prmSourceQueueId != null
&& prmSourceQueueId != "") {
|
wod_Request += "
<a:KeyValuePairOfstringanyType>";
|
wod_Request += "
<c:key>SourceQueueId</c:key>";
|
wod_Request += " <c:value
i:type=\"d:guid\"
xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" +
prmSourceQueueId + "</c:value>";
|
wod_Request += "
</a:KeyValuePairOfstringanyType>";
|
}
|
wod_Request += " </a:Parameters>";
|
wod_Request += " <a:RequestId
i:nil=\"true\" />";
|
wod_Request += "
<a:RequestName>AddToQueue</a:RequestName>";
|
wod_Request += " </request>";
|
wod_Request += " </Execute>";
|
wod_Request += " </s:Body>";
|
wod_Request += "</s:Envelope>";
|
var req = new XMLHttpRequest();
|
req.open("POST",
wod_SDK.QueuesLib._getServerUrl(), false)
|
req.setRequestHeader("Accept", "application/xml,
text/xml, */*");
|
req.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
|
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
|
req.send(wod_Request);
|
//Checking if error occurs
|
var errorMessage =
wod_SDK.QueuesLib._getError(req.responseXML);
|
if (errorMessage != "") {
|
alert(errorMessage);
|
}
|
},
|
_getError: function (faultXml) {
|
///<summary>
|
/// Parses the WCF fault returned in the event
of an error.
|
///</summary>
|
///<param name="faultXml"
Type="XML">
|
/// The responseXML property of the
XMLHttpRequest response.
|
///</param>
|
var errorMessage = "";
|
if (typeof faultXml == "object") {
|
try {
|
var
bodyNode = faultXml.firstChild.firstChild;
|
//Retrieve the fault node
|
for (var i = 0;
i < bodyNode.childNodes.length; i++) {
|
var node = bodyNode.childNodes[i];
|
//NOTE: This comparison
does not handle the case where the XML namespace changes
|
if ("s:Fault" ==
node.nodeName) {
|
for (var j = 0;
j < node.childNodes.length; j++) {
|
var
faultStringNode = node.childNodes[j];
|
if ("faultstring" ==
faultStringNode.nodeName) {
|
errorMessage
= faultStringNode.text;
|
break;
|
}
|
}
|
break;
|
}
|
}
|
}
|
catch (e) { };
|
}
|
return errorMessage;
|
},
|
__namespace: true
|
};
|
// Function Call : Source
Queue Id (optional may pass null), Destination Queue Id (required),
|
// Entity Logical Name
(required), Entity GUID (required)
|
wod_SDK.QueuesLib.AddToQueueRequest(null,
DestinationQueueId "incident", IncidentGUID);
|
[Plugin Usage Example]
using System;
|
using
System.Collections.Generic;
|
using
System.Linq;
|
using
System.Text;
|
using
Microsoft.Xrm.Sdk;
|
using
Microsoft.Crm.Sdk;
|
namespace
wod.Crm.AddToQueuePlugin
|
{
|
public class wodPlugin : IPlugin
|
{
|
public void Execute(IServiceProvider serviceProvider)
|
{
|
// Obtain the execution context from the service
provider.
|
IPluginExecutionContext context
= (IPluginExecutionContext)
|
serviceProvider.GetService(typeof(IPluginExecutionContext));
|
try
|
{
|
switch
(context.MessageName)
|
{
|
case "AddToQueue":
|
Guid
wod_SourceQueueId = Guid.Empty, wod_DestinationQueueId = Guid.Empty;
|
EntityReference
wod_EntityReference = null;
|
// SourceQuueId paramter
(optional) will only pass if record will be moved
|
// from one queue to another
|
if
(context.InputParameters.Contains("SourceQueueId"))
|
{
|
wod_SourceQueueId
= (Guid)context.InputParameters["SourceQueueId"];
|
}
|
// Destination Queue Id,
record will be added to this queue
|
wod_DestinationQueueId
= (Guid)context.InputParameters["DestinationQueueId"];
|
// Entity record Reference
which will be added to the destination queue
|
wod_EntityReference =
(EntityReference)context.InputParameters["Target"];
|
break;
|
}
|
}
|
catch (System.Web.Services.Protocols.SoapException ex)
|
{
|
throw new InvalidPluginExecutionException(ex.Detail.InnerText);
|
}
|
catch (Exception ex)
|
{
|
throw new InvalidPluginExecutionException(ex.Message);
|
}
|
}
|
}
|
}
|
The blog is absolutely fantastic. Lots of great information and inspiration, both of which we all need. Thanks.
ReplyDeleteThank you for your compliments :) and i hope to publish soon new articles and free CRM utilities.
ReplyDeleteThats very good . i think this information really help me . Thanks.
ReplyDeleteHello Javeed,
ReplyDeleteI am looking at a requirement where we can change the WorkOn to different users instead of queue routing. Is that a possibility using C#?
This comment has been removed by the author.
ReplyDeleteInformative blog. Thank you for sharing with us.
ReplyDeleteMicrosoft Dynamics AX Online Training
I'm constantly searching on the internet for posts that will help me. Too much is clearly to learn about this. I believe you created good quality items in Functions also. Keep working, congrats! Microsoft Dynamics GP Support
ReplyDeletesadsad
ReplyDeletehogan outlet online
ReplyDeleteconverse shoes
golden gooses sneakers
kd 11 shoes
jordan 1 off white
kd shoes
nike air max 97
off-white
golden goose
nike air max
golden goose francy
sadsadsadxiaofang20191212
The following examples below can be use to add an entity record to the Queue via a process Workflow, Jscript, C# code and also explains how to use plugin code for AddToQueue plugin message.
ReplyDeletekurti stitching factory ,
stitching factory in pakistan ,
quite nice say. I just stumbled upon your weblog and wanted to publicize that i've without a doubt enjoyed browsing your weblog posts. After every sick be subscribing on your feed and that i dream you write inside the same manner as again quickly! Avast Secureline VPN Subscription Code
ReplyDeleteattractive, notice. I simply stumbled upon your blog and wanted to proclaim that i've appreciated browsing your weblog posts. After every one in all proportion of share of, i can really subscribe to your feed, and that i goal you may write once more quickly! Spyhunter 5 Crack Download
ReplyDeletereplica louis vuitton bags h53 y2u34l5y71 cheap designer bags replica r81 j7f75f2t31 replica wallets g31 w9c13s9d42
ReplyDeleteشركة تنظيف مجالس بالدمام
ReplyDeleteشركة تنظيف مجالس
So, I appear to the particular Mushroom Growing picked woodland and I consider the woods and shrubs. I mind towards maple and spruce woods checking at the surface which can be lined by maple and spruce great needles. From time to time, here and there I see green moss.
ReplyDeleteI recently came across your blog post discussing MS Dynamics, and I must say it's an excellent resource for businesses seeking insights into this powerful business management solution.
ReplyDeleteMicrosoft Dynamics has revolutionized the way organizations operate, providing a comprehensive suite of applications that streamline operations, enhance customer relationships, and drive growth. It offers a range of features and benefits that enable businesses to thrive in today's competitive landscape.
Nice a post if you want meet her call now
ReplyDeleteThis request may involve actions related to queuing or managing tasks within the Dynamics CRM platform. Ootdtak Pernah Kot For a complete understanding or specific instructions, further context or details about the task are needed.
ReplyDeleteIn this example, replace "source_queue_id" with the ID of the source queue, "destination_queue_id" with the ID of the destination queue, Ootdtak Kot Pernah "entity_name" with the logical name of the entity, and "record_id" with the ID of the record you want to add.
ReplyDelete