我想將記錄分配給我的Silverlight應用程序中的特定隊列。Dynamics CRM 2011 - 如何使用REST端點和Silverlight將記錄添加到隊列(隊列項)
我顯示記錄列表,用戶可以選擇一個或多個記錄。然後我顯示一個隊列列表,並且用戶選擇他想要添加這些記錄的隊列。
我已經按照這個例子:
http://msdn.microsoft.com/en-us/library/gg309558.aspx
我嘗試了不同的方式,但它從來沒有工作。
首先,
我試圖建立一個「空」 QueueItem:(代碼的某些部分缺失,例如這裏沒有排隊記錄,但是這並不重要,它只是向您展示問題)
internal void AddBillingToQueue()
{
QueueItem item = new QueueItem();
context.AddToQueueItemSet(item);
context.BeginSaveChanges(OnCreateCompleted, item);
}
private void OnCreateCompleted(IAsyncResult result)
{
QueueItem item = result.AsyncState as QueueItem
DataServiceResponse response = context.EndSaveChanges(result);
// Normally, the GUID shouldn't be empty anymore,
// but it fails at the EndSaveChanges line.
}
異常消息表示objecttypecode丟失。所以我再次嘗試提供我想放入隊列中的對象。
internal void AddBillingToQueue(all_billing billing)
{
QueueItem item = new QueueItem();
item.ObjectId = new EntityReference()
{
Name = billing.all_name,
Id = billing.all_billingId,
LogicalName = "all_billing"
}
context.AddToQueueItemSet(item);
context.BeginSaveChanges(OnCreateCompleted, item);
}
private void OnCreateCompleted(IAsyncResult result)
{
QueueItem item = result.AsyncState as QueueItem
DataServiceResponse response = context.EndSaveChanges(result);
// again it fails
}
現在異常消息說明QueueId丟失。所以我也嘗試提供對Queue的引用。
internal void AddBillingToQueue(all_billing billing, Queue queue)
{
QueueItem item = new QueueItem();
item.ObjectId = new EntityReference()
{
Name = billing.all_name,
Id = billing.all_billingId,
LogicalName = "all_billing"
}
item.QueueId = new EntityReference()
{
Name = queue.Name,
Id = queue.QueueId,
LogicalName = "Queue"
};
context.AddToQueueItemSet(item);
context.BeginSaveChanges(OnCreateCompleted, item);
}
private void OnCreateCompleted(IAsyncResult result)
{
QueueItem item = result.AsyncState as QueueItem
DataServiceResponse response = context.EndSaveChanges(result);
// again it fails
}
這裏,異常消息是這一個:
<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>
<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">
<code>-2147217150</code>
<message xml:lang=\"nl-BE\">Queue</message>
</error>
據本網(http://www.cub-e.net/post/Microosft-Dynamics-CRM-Error-Code-List.aspx),代碼的意思是:找不到指定的實體。我想這意味着隊列還沒找到。
但是,所提供的GUID是絕對正確的,因爲它已從相同的上下文中檢索到。
所以,如果我提供了隊列ID,它就會失敗。如果我不這樣做,它就會失敗。我錯過了什麼?有人已經使用QueueItem和REST端點嗎?
我試了很多次!我錯過了它怎麼可能?當然,它應該是小寫:)謝謝指出! –