我正在尝试将成员添加到 CRM 2011 工作流活动中的营销列表。在它执行下面的代码之后,它说 fromListCreated 的成员计数是 0,而它应该是 1。我已经验证过members[0]
并且AddMemberRequest.MemberIds[0]
确实包含一个成员 GUID。有谁知道我错过了什么?
List fromList = new List();
List fromListCreated = new List();
fromList.CreatedFromCode = new OptionSetValue(2);
fromList.ListName = "My List";
Guid fromListGuid = service.Create(fromList);
var list = service.Retrieve("list", fromListGuid, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
fromListCreated = service.Retrieve(list.LogicalName, list.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(true)).ToEntity<List>();
Guid emailFrom = Guid.Empty;
if (EmailFrom != null)
{
emailFrom = EmailFrom.Get(executionContext).Id;
}
else
{
// Default to the inhouse attorney user
emailFrom= thisCase.lgl_inhouseattorneyid.Id;
}
Guid[] members = new Guid[1];
members[0] = emailFrom;
AddListMembersListRequest AddMemberRequest = new AddListMembersListRequest();
AddMemberRequest.ListId = fromListCreated.Id;
AddMemberRequest.MemberIds[0] = members[0];
AddListMembersListResponse AddMemberResponse = service.Execute(AddMemberRequest) as AddListMembersListResponse;
service.Update(fromListCreated);