web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Plugin to create multiple tasks

(4) ShareShare
ReportReport
Posted on by 37
New to Plugins / C#  coding- followed this tutorial and worked perfectly.
 
 
I want to modify the code though to add multiple tasks instead of just one. and create them when a drop-down column value changes in an account instead of when a new account is created 
Original Business logic that works 
 
                try
                {
                    // Create a task activity to follow up with the account customer in 7 days. 
                    Entity followup = new Entity("task");
                    followup["subject"] = "Send e-mail to the new customer.";
                    followup["description"] =
                        "Follow up with the customer. Check if there are any new issues that need resolution.";
                    followup["scheduledstart"] = DateTime.Now.AddDays(7);
                    followup["scheduledend"] = DateTime.Now.AddDays(7);
                    followup["category"] = context.PrimaryEntityName;
                    // Refer to the account in the task activity.
                    if (context.OutputParameters.Contains("id"))
                    {
                        Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());
                        string regardingobjectidType = "account";
                        followup["regardingobjectid"] =
                        new EntityReference(regardingobjectidType, regardingobjectid);
                    }
                    // Create the task in Microsoft Dynamics CRM.
                    tracingService.Trace("FollowupPlugin: Creating the task activity.");
                    service.Create(followup);
                }
                catch (FaultException<OrganizationServiceFault> ex)
                {
                    throw new InvalidPluginExecutionException("An error occurred in FollowUpPlugin.", ex);
                }
                catch (Exception ex)
                {
                    tracingService.Trace("FollowUpPlugin: {0}", ex.ToString());
                    throw;
                }
            }
            throw new NotImplementedException();
        }
    }
}
    
 
NEW - Add Multiple tasks - not just one - where / how do I add this code? 
 
 
 
Entity followup = new Entity("task");
        followup["subject"] = "Send e-mail to the new customer.";
        followup["description"] =
            "Follow up with the customer. Check if there are any new issues that need resolution.";
        followup["scheduledstart"] = DateTime.Now.AddDays(7);
        followup["scheduledend"] = DateTime.Now.AddDays(7);
        followup["category"] = context.PrimaryEntityName;
        // Refer to the account in the task activity.
 
  followup["subject"] = "Call the  new customer.";
        followup["description"] =
            "Follow up with the customer. Call them back";
        followup["scheduledstart"] = DateTime.Now.AddDays(7);
        followup["scheduledend"] = DateTime.Now.AddDays(7);
        followup["category"] = context.PrimaryEntityName;
 
  followup["subject"] = "Create customer portfolio .";
        followup["description"] =
            "Create portfolio for customer";
        followup["scheduledstart"] = DateTime.Now.AddDays(5);
        followup["scheduledend"] = DateTime.Now.AddDays(5);
        followup["category"] = context.PrimaryEntityName;
 
  followup["subject"] = "Begin Presentation.";
        followup["description"] =
            "Create sales deck.";
        followup["scheduledstart"] = DateTime.Now.AddDays(7);
        followup["scheduledend"] = DateTime.Now.AddDays(7);
        followup["category"] = context.PrimaryEntityName;
 
What do I have to change to get this to trigger when a value is updated instead of when a record is created? 
 
Thank you. 
I have the same question (0)
  • Verified answer
    Jonas "Jones" Melgaard Profile Picture
    5,010 Most Valuable Professional on at
     
    If you want to trigger your plugin when a record is updated, you can register a new step for the message type update.
    In short: Register step for message, filter by the column with the drop-down, and update your code so that it's only running if the actual value has changed.
     
    Question is, when exactly do you want to trigger it? When the record is saved to Dataverse, or when you modify it from the user interface.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 174

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Niki Patel Profile Picture

Niki Patel 42

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans