0
votes

I am trying to add a member to a marketing list in a CRM 2011 workflow activity. After it performs the below code, it's saying that the fromListCreated member count is 0, when it should be 1. I have verified that members[0] and AddMemberRequest.MemberIds[0] does indeed contain a member GUID. Does anyone know what I'm missing?

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);
1
Can't see anything missing. What are you receiving in response?Scorpion

1 Answers

0
votes

As far as I can see:

fromListCreated has not been updated after the AddListMembersListRequest. This object won't be updated by any crm request. I believe this object should be updated back by retrieve request.

Has the member been added to the marketing list?