Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Plug-in try to get Campaign Activity relationship with email

$
0
0

Hello everyone,


I am new in the CRM world and I do need some help to understand better how does it work.

What I need to do is: "after that a campaign activity, with channel email, has been distributed I need to count all emails generated."

What I did was to create a Plug-in that will start on status reason update (is there a better way?), then will check if the status reason is equal to 6 (completed) and finally tries to count the email generated. As for the email, what I do to count is:

if (statusReasonVal == 6)
{
   tracingService.Trace("The status reason is 'completed'");
   Relationship rel = new Relationship("CampaignActivity_Emails");
   int emailCount = -1;
   if (campaignActivity.RelatedEntities.Contains(rel))
   {
      emailCount = campaignActivity.RelatedEntities[rel].Entities.Count();
   }
   tracingService.Trace("email created: {0}", emailCount);
} 

the result is always -1 because, while debugging, the campaign activity entity variable does not contain any relationship.

Am I doing it in the wrong way?

Thanks in advance for the reply

Andrea


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>