开发者

Dynamics crm 2011 addlink with relationship campaignlist_association

Relationship relation = new Relationship("campaignlist_association");
Entity campaign = (from c in orgServiceContext.CreateQuery("campaign")
               select c).FirstOrDefault<Entity>();
foreach (Guid id in listsMarketingGuid)
{
    Entity list = (from l in orgServiceContext.CreateQuery("list")
               where l["listid"].Equals(id)
               select l).FirstOrDefault<Ent开发者_开发知识库ity>();
    orgServiceContext.AddLink(campaign, relation, list);
    orgServiceContext.AddLink(list, relation, campaign);
}
orgServiceContext.SaveChanges();

I would like to add a relation between a marketing list and a campaign but when the SaveChanges statment is executed I got an error "Associate is not supported for CampaignItem". Do you any idea ? Thanks


use Associate method as for building relationship:

_service.Associate(EntityLogicalName,EntityId,relationship,relatedEntities);

where EntityLogicalName is name of entity EntityId is id of entity relationship:wat kind of relationship relatedentities:to which entiites u want to build relation of above entity.


it needs to call method AddItemCampaignRequest


I got the error

"Associate is not supported for CampaignItem"

when trying to associate product to campaign. This worked for me:

var request = new AddItemCampaignRequest
{
    CampaignId = yourCampaign.Id,
    EntityId = productToAssociate.Id,
    EntityName = ProductEntity.EntityLogicalName,
};
_serviceProxy.Execute(request);

Creds to Mitch Milam

Hope this will help someone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜