从 Javascript 调用操作失败 MSCRM
Calling Action From Javascript Fails MSCRM
我有一些东西可以协同工作以完成队列中的多个任务。
第一个是 javascript,它调用一个操作(工作流)来处理任务 ID 和用户 ID 的 CSV。此操作将其全部交给循环任务的插件,为用户挑选它们,然后将它们设置为完成。
这一切都运行良好,除非已经分配了任务。然后我从 javascript.
得到一个错误
起初这是在说 "Item has already been assigned to another user"。但是我添加了一个 try catch
try
{
Entity queueItem = RetrieveQueueItemIdByObjectId(service, new Guid(taskId));
// Create the Request Object and Set the Request Object's Properties
PickFromQueueRequest pickFromQueueRequest = new PickFromQueueRequest
{
QueueItemId = queueItem.Id,
WorkerId = new Guid(_UserId)
};
// Execute the Request
service.Execute(pickFromQueueRequest);
}
catch(FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
{
if (ex.Detail.ErrorCode != -2147220891)
{
throw ex;
}
}
我已经尝试过
if(!ex.Message.Contains("Item has already been assigned to another user"))
{
throw ex;
}
然后抓住一切。然而错误仍然存在。然后我注意到任务正在完成,但错误正在被抛出。在此代码之后是设置任务完成的地方。这是有效的,因为如果尚未选择任务,则不会引发错误。
答案在错误中:在插件中,您不能 catch
OrganizationService
抛出的异常(或据我所知,实际上是任何异常)并继续 运行。
您必须扩展您的代码,以便它不会抛出如果您想让它工作。没有办法解决这个问题。
and just catching everything. And yet the error still shows. I then noticed the tasks were completing, but the error is getting thrown. After this code is where the task is set to complete. Which works because if the task is not already picked, no error is thrown.
因为已经分配了这条记录,所以跳过这条记录如何?基本上你必须在再次选择之前释放这个队列项目。
我有一些东西可以协同工作以完成队列中的多个任务。
第一个是 javascript,它调用一个操作(工作流)来处理任务 ID 和用户 ID 的 CSV。此操作将其全部交给循环任务的插件,为用户挑选它们,然后将它们设置为完成。
这一切都运行良好,除非已经分配了任务。然后我从 javascript.
得到一个错误起初这是在说 "Item has already been assigned to another user"。但是我添加了一个 try catch
try
{
Entity queueItem = RetrieveQueueItemIdByObjectId(service, new Guid(taskId));
// Create the Request Object and Set the Request Object's Properties
PickFromQueueRequest pickFromQueueRequest = new PickFromQueueRequest
{
QueueItemId = queueItem.Id,
WorkerId = new Guid(_UserId)
};
// Execute the Request
service.Execute(pickFromQueueRequest);
}
catch(FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
{
if (ex.Detail.ErrorCode != -2147220891)
{
throw ex;
}
}
我已经尝试过
if(!ex.Message.Contains("Item has already been assigned to another user"))
{
throw ex;
}
然后抓住一切。然而错误仍然存在。然后我注意到任务正在完成,但错误正在被抛出。在此代码之后是设置任务完成的地方。这是有效的,因为如果尚未选择任务,则不会引发错误。
答案在错误中:在插件中,您不能 catch
OrganizationService
抛出的异常(或据我所知,实际上是任何异常)并继续 运行。
您必须扩展您的代码,以便它不会抛出如果您想让它工作。没有办法解决这个问题。
and just catching everything. And yet the error still shows. I then noticed the tasks were completing, but the error is getting thrown. After this code is where the task is set to complete. Which works because if the task is not already picked, no error is thrown.
因为已经分配了这条记录,所以跳过这条记录如何?基本上你必须在再次选择之前释放这个队列项目。