locked
How do i add an activity item to a queue. RRS feed

  • Question

  • I want to add an activity I have created using c# code to a queue. Has anyone seen code which does this? 
    Thursday, October 6, 2011 2:38 PM

Answers

  • You need to use the AddToQueueRequest: http://msdn.microsoft.com/en-us/library/gg327483.aspx

     

    // Move a record from a source queue to a destination queue
    // by using the AddToQueue request message.
    AddToQueueRequest routeRequest = new AddToQueueRequest
    {
        SourceQueueId = _sourceQueueId,
        Target = new EntityReference(Letter.EntityLogicalName, _letterId),
        DestinationQueueId = _destinationQueueId
    };
    
    // Set the WorkerId of the QueueItemProperties to indicate who is working
    // on this particular queue item. If there were any custom attributes
    // defined for the QueueItem Entity, it would be possible to set
    // those here, as well.
    routeRequest.QueueItemProperties = new QueueItem
    {
        WorkerId = new EntityReference("systemuser", _userId),
    };
    
    // Execute the Request
    _serviceProxy.Execute(routeRequest);
    
    

     

    You only need to specify the SourceQueueId attribute if the activity is already in a queue and you want to route it to another queue. For adding an item to a queue that was not in a queue just ignore that attribute


    Gonzalo | gonzaloruizcrm.blogspot.com


    Thursday, October 6, 2011 2:41 PM
    Moderator

All replies

  • You need to use the AddToQueueRequest: http://msdn.microsoft.com/en-us/library/gg327483.aspx

     

    // Move a record from a source queue to a destination queue
    // by using the AddToQueue request message.
    AddToQueueRequest routeRequest = new AddToQueueRequest
    {
        SourceQueueId = _sourceQueueId,
        Target = new EntityReference(Letter.EntityLogicalName, _letterId),
        DestinationQueueId = _destinationQueueId
    };
    
    // Set the WorkerId of the QueueItemProperties to indicate who is working
    // on this particular queue item. If there were any custom attributes
    // defined for the QueueItem Entity, it would be possible to set
    // those here, as well.
    routeRequest.QueueItemProperties = new QueueItem
    {
        WorkerId = new EntityReference("systemuser", _userId),
    };
    
    // Execute the Request
    _serviceProxy.Execute(routeRequest);
    
    

     

    You only need to specify the SourceQueueId attribute if the activity is already in a queue and you want to route it to another queue. For adding an item to a queue that was not in a queue just ignore that attribute


    Gonzalo | gonzaloruizcrm.blogspot.com


    Thursday, October 6, 2011 2:41 PM
    Moderator
  • Cheers,

     

    this bit of code here.

     

    routeRequest.QueueItemProperties = new QueueItem
    {
        WorkerId = new EntityReference("systemuser", _userId),
    };

    is this the entityreference to the queue record and its guid

    Thursday, October 6, 2011 2:49 PM
  • That part is the reference to the user who is "working on" the queue item, it is only an option part if you want to assign the queue item to someone to work on it. If you just want to add the item to a queue you can ignore that part

    Gonzalo | gonzaloruizcrm.blogspot.com

    Thursday, October 6, 2011 2:52 PM
    Moderator
  • how would i retrieve the destinationQueueId?
    Thursday, October 6, 2011 3:33 PM
  • If you don't know the id of the queue you can always get it by navigating to Settings --> Business Management --> Queues.

    Open the queue you need and you will see the id in the window title. You can also copy a link and the link will include the GUID of the queue:


    Gonzalo | gonzaloruizcrm.blogspot.com

    Thursday, October 6, 2011 3:38 PM
    Moderator