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

Community site session details

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

Plugins

(0) ShareShare
ReportReport
Posted on by 19
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)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
DAnny3211 Profile Picture

DAnny3211 338

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 137 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 87 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans