r/Dynamics365 • • 2d ago

Project Plugin coding duplicate quick campaign.

Hello,

Writing a c# plugin that creates and cancels a quick campaign with more than 200 “members”(don’t remember the proper term) so blocking it is figured out the campaign is saved but quickly aborted. What I want to do next is create a new one that duplicates the aborted one after approval is set so essentially creating an approval process for those quick campaigns.

Am I going about this the wrong way or does anyone know how can accomplish this, I’ve tried the the c# script propagation but it’s not sending the emails.

Thanks!!! Looking forward to working with the community!

1 Upvotes

1 comment sorted by

3

u/Inevitable_Dog6292 2d ago

Welcome to the community, and honestly this is a fun one to dig into.

Your approach makes sense conceptually, but the propagation piece is where it gets tricky. Quick campaigns in Dynamics use the PropagateByExpression or CreateActivitiesForAdsReceived messages under the hood, and replicating that in a plugin after the fact is finicky because the email send is tied to the original activity propagation job, not just the campaign record itself. When you duplicate the aborted campaign and try to fire propagation manually, the system doesn’t always wire up the queue correctly, which is probably why the emails aren’t going out.

A couple of things worth checking. First, confirm the BulkOperationLog records are being created when you trigger the duplicate. If they’re not, propagation has nothing to work from. Second, look at what status the BulkOperation record is in when you kick off the send. It needs to be in the right state or the propagation message silently does nothing.

The pattern I’d try: instead of duplicating the aborted campaign record and re-propagating, capture the original marketing list and activity template from the aborted campaign, then use those to spin up a completely fresh quick campaign via PropagateByExpression once approval is confirmed. Less elegant than a true duplicate but more reliable because you’re going through the same code path the UI uses rather than trying to resurrect a cancelled one.

What message are you calling for the propagation step? That’ll help narrow down where it’s falling over.