开发者

Dynamics crm 2011 addlink with relationship campaignlist_association

开发者 https://www.devze.com 2023-04-01 03:59 出处:网络
Relationship relation = new Relationship(\"campaignlist_association\"); Entity campaign = (from c in orgServiceContext.CreateQuery(\"campaign\")
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

精彩评论

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