积极答复者
怎么用CrmWebservice修改CRM用户的业务部门?

问题
-
我的代码执行成功可是业务部门没被改掉?
//判断上级部门是不是改变
string userBusinessunitId =((Lookup)userEntity.Properties["businessunitid"]).Value.ToString();
if (BusinessunitId != userBusinessunitId)
{
LookupProperty SysBusinessUnit = new LookupProperty();
SysBusinessUnit.Name = "businessunitid";
SysBusinessUnit.Value = new Lookup();
SysBusinessUnit.Value.Value = new Guid(BusinessunitId);
UpdateEntity.Properties.Add(SysBusinessUnit); // 更改 业务部门 字段
}CrmService.Update(UpdateEntity);
能成功执行代码,业务部门未改变,也没有报错
CRM----BEST
答案
-
那就用 SetBusinessSystemUser message
// Create the request object.
SetBusinessSystemUserRequest user = new SetBusinessSystemUserRequest();
// Set the properties of the request object.
user.BusinessId = new Guid("97110FB7-84A1-DB11-BEB5-0013727B635D");
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.PrincipalId = new Guid("59727AF6-09A0-DB11-BEB5-0013727B635D");
user.ReassignPrincipal = assignee;
user.UserId = new Guid("59727AF6-09A0-DB11-BEB5-0013727B635D");
// Execute the request.
SetBusinessSystemUserResponse assigned = (SetBusinessSystemUserResponse) service.Execute(user);
刀客 | MSN:caims@techsun.com | BLOG:http://caims.cnblogs.com | 提供微软CRM高级开发顾问外包- 已标记为答案 王红福 2011年3月23日 12:56
全部回复
-
Please use the SetParentBusinessUnit Message.
// Create the request object.
SetParentBusinessUnitRequest request = new SetParentBusinessUnitRequest();
// Set the properties of the request object.
request.BusinessUnitId = createdId;
request.ParentId = user.BusinessUnitId;
// Execute the request.
SetParentBusinessUnitResponse response = (SetParentBusinessUnitResponse) service.Execute(request);
刀客 | MSN:caims@techsun.com | BLOG:http://caims.cnblogs.com | 提供微软CRM高级开发顾问外包
-
是的,
businessunit.parentbusinessunitid Property
Gets or sets the ID for the parent business unit.
Syntax
[Visual Basic .NET] Public Property parentbusinessunitid As Lookup
[C#] public Lookup parentbusinessunitid {get; set;}
Property Value
The value of this property is a Lookup type.
Remarks
To change this property, use the Execute method with the message SetParentBusinessUnit.
刀客 | MSN:caims@techsun.com | BLOG:http://caims.cnblogs.com | 提供微软CRM高级开发顾问外包 -
刀哥,我要修改的是这个字段
systemuser.businessunitid Property
Gets or sets the ID of the business unit with which the user is associated.
Syntax
[Visual Basic .NET] Public Property businessunitid As Lookup
[C#] public Lookup businessunitid {get; set;}
Property Value
The value of this property is a Lookup type.
Remarks
The following table contains additional information about this property:
CRM----BEST -
那就用 SetBusinessSystemUser message
// Create the request object.
SetBusinessSystemUserRequest user = new SetBusinessSystemUserRequest();
// Set the properties of the request object.
user.BusinessId = new Guid("97110FB7-84A1-DB11-BEB5-0013727B635D");
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.PrincipalId = new Guid("59727AF6-09A0-DB11-BEB5-0013727B635D");
user.ReassignPrincipal = assignee;
user.UserId = new Guid("59727AF6-09A0-DB11-BEB5-0013727B635D");
// Execute the request.
SetBusinessSystemUserResponse assigned = (SetBusinessSystemUserResponse) service.Execute(user);
刀客 | MSN:caims@techsun.com | BLOG:http://caims.cnblogs.com | 提供微软CRM高级开发顾问外包- 已标记为答案 王红福 2011年3月23日 12:56