tdg*_*gdr 5 c# dynamics-crm ownership assign dynamics-crm-2011
在我们的应用程序中,我们创建了几千个电话呼叫记录.每个电话呼叫应具有不同的所有者,由名为GetAnyAppropriateSystemUser()的方法确定,该方法根据某些条件查找一些随机的SystemUser.
在下面的代码示例中,我们创建了一个电话呼叫,稍后在其上使用AssignRequest来指定其所有者.
PhoneCall phoneCall = new PhoneCall();
//
// stuff to set up the new PhoneCall instance here; populate fields, etc...
//
// determine this phonecall's owner through some algorithm
Guid appropriateOwner = GetAnyAppropriateSystemUser();
Guid createdPhoneCallId = _serviceProxy.Create(phoneCall);
if (createdPhoneCallId != Guid.Empty)
{
AssignRequest phoneCallAssign = new AssignRequest();
phoneCallAssign.Assignee = new EntityReference(SystemUser.EntityLogicalName, appropriateOwner);
phoneCallAssign.Target = new EntityReference(PhoneCall.EntityLogicalName, createdPhoneCallId);
_serviceProxy.Execute(phoneCallAssign);
}
Run Code Online (Sandbox Code Playgroud)
这可以正常工作,但有两个调用,一个用于创建,另一个用于分配.在调用Create()方法之前设置PhoneCall记录的"ownerid"是否可以,从而无需在以后调用AssignRequest?它似乎工作,我甚至找到了一个在SDK中做类似事情的例子,如下所示.
SDK示例:针对目标收入汇总自定义期间的目标数据
// Create three goals: one parent goal and two child goals.
Goal parentGoal = new Goal()
{
Title = "Parent Goal Example",
RollupOnlyFromChildGoals = true,
ConsiderOnlyGoalOwnersRecords = true,
TargetMoney = new Money(300.0M),
IsFiscalPeriodGoal = false,
MetricId = new EntityReference
{
Id = _metricId,
LogicalName = Metric.EntityLogicalName
},
GoalOwnerId = new EntityReference
{
Id = _salesManagerId,
LogicalName = SystemUser.EntityLogicalName
},
OwnerId = new EntityReference
{
Id = _salesManagerId,
LogicalName = SystemUser.EntityLogicalName
},
GoalStartDate = DateTime.Today.AddDays(-1),
GoalEndDate = DateTime.Today.AddDays(30)
};
_parentGoalId = _serviceProxy.Create(parentGoal);
Run Code Online (Sandbox Code Playgroud)
虽然它似乎有用,但是如果我们在创建新记录之前设置ownerid,我们必须注意什么吗?有什么不同吗?
非常感谢你提前.
正如您已经发现的那样,您可以在创建记录时设置ownerid.
但是不可能以相同的方式编辑现有记录的所有者,在这种情况下,您必须使用AssignRequest.
还检查这个问题: ETL Software,无法检索联系人的所有者
| 归档时间: |
|
| 查看次数: |
11089 次 |
| 最近记录: |