分配新主人约会。 "这里应该只有一个用于活性QUOT业主方; [英] Assign new owner to appointment. "There should be only one owner party for an activity"

查看:145
本文介绍了分配新主人约会。 "这里应该只有一个用于活性QUOT业主方;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个新的约会时,更改约会记录的所有者。我使用的创建消息的插件,我发现这段代码来分配新东家的任命:

 实体= context.PostEntityImages [PostImage]; 

......

AssignRequest要求=新AssignRequest();

//request.RequestName
request.Assignee =新的EntityReference(systemuser,owners.ToList()[0] .ID);
request.Target =新的EntityReference(Appointment.EntityLogicalName,entity.Id);
service.Execute(请求);



但是,当我测试这个我得到以下错误:无效的参数:应该只有一个业主方为活动



我想我必须先删除当前的所有者,然后分配新的所有者。但我怎么能这样做呢?

任何帮助!


解决方案
<

谢谢p>我在做与任务(在一个插件重新分配它们)类似的东西。作为一个更新插件,它没有任何问题,但为创造,它会失败消息应该只有一个活动所有者党



要解决这种变化的创建插件简单地设置OWNERID(而不是执行AssignRequest)。

  targetEntity.Attributes [OWNERID] =新的EntityReference(SystemUser.EntityLogicalName,assignTo.Id); 

这代码放在预操作阶段。


I need to change the owner of an appointment record when creating a new appointment. I'm using a plugin for the create message and i've found this code to assign a new owner to the appointment:

entity = context.PostEntityImages["PostImage"];

......

AssignRequest request = new AssignRequest();

//request.RequestName
request.Assignee = new EntityReference("systemuser", owners.ToList()[0].Id);
request.Target = new EntityReference(Appointment.EntityLogicalName, entity.Id);
service.Execute(request);

But when I test this i get the following error: Invalid Argument: There should be only one owner party for an activity

I guess i have to remove the current owner first and then assign the new owner. But how can i do this?

Thanks for any help!

解决方案

I was doing something similar with tasks (reassigning them in a plugin). As a "Update" plugin it didn't have any problems, but as "Create" it would fail with the message "There should be only one owner party for an activity"

To fix this change the "Create" plugin to simply set the ownerid (instead of executing the AssignRequest).

targetEntity.Attributes["ownerid"] = new EntityReference(SystemUser.EntityLogicalName, assignTo.Id);

This code goes in the Pre-operation stage.

这篇关于分配新主人约会。 &QUOT;这里应该只有一个用于活性QUOT业主方;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆