Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Plug-in try to get Campaign Activity relationship with email

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans