![]() ![]() with the following: // Create a task activity to follow up with the account customer in 7 days.įollowup = "Send e-mail to the new customer." Replace the comment: // Plug-in business logic goes here. The plug-in will create a task activity that will remind the creator of the account to follow up one week later.Īdd the following code to the try block. ![]() The IOrganizationServiceFactory interface provides access to a service variable that implements the IOrganizationService interface which provides the methods you will use to interact with the service to create the task.If the Target property is present, the Entity that was passed to the request will be available. The code verifies that the context InputParameters includes the expected parameters for the CreateRequest that this plug-in will be registered for.More information: Understand the execution context. The IPluginExecutionContext provides access to the context for the event that executed the plugin.You can see an example in the final catch block. The ITracingService enables writing to the tracing log. ![]() TracingService.Trace("FollowUpPlugin: ", ex.ToString()) Throw new InvalidPluginExecutionException("An error occurred in FollowUpPlugin.", ex) IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId) (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)) IOrganizationServiceFactory serviceFactory = Obtain the organization service reference which you will need for Obtain the target entity from the input parameters.Įntity entity = (Entity)context.InputParameters If (("Target") &Ĭontext.InputParameters is Entity) The InputParameters collection contains all the data passed in the message request. ServiceProvider.GetService(typeof(IPluginExecutionContext)) IPluginExecutionContext context = (IPluginExecutionContext) Obtain the execution context from the service provider. (ITracingService)serviceProvider.GetService(typeof(ITracingService)) Replace the contents of the Execute method with the following code: Public void Execute(IServiceProvider serviceProvider) If you just type : IPlugin after the class name, Visual Studio will auto-suggest implementing a stub for the Execute Method. Implement the IPlugin interface by editing the class. When prompted, allow Visual Studio to re-name the class to match the file name.Īdd the following using statements to the top of the FollowupPlugin.cs file: using System.ServiceModel Rename the Class1.cs file to FollowupPlugin.cs. In Solution Explorer, right-click the Class1.cs file and choose Rename in the context menu. You cannot assume that the assemblies other than those included in the NuGet package will be present on the server and compatible with your code. You cannot include these assemblies when you register the assembly with your logic. These assemblies are already present in the sandbox runtime.ĭo not include any other NuGet packages or assemblies to the build folder of your project. You must select I Accept in the License Acceptance dialog.Īdding the NuGet package will include these assemblies in the build folder for your assembly, but you will not upload these assemblies with the assembly that includes your logic. Select Browse and search for and install the latest version. In Solution Explorer, right-click the project and select Manage NuGet Packages… from the context menu. The name used for the project will be the name of the assembly. ![]() Open Visual Studio and open a new Class Library (.NET Framework) project using. Create a Visual Studio project for the plug-in You can also find the complete plug-in solution files here: Sample: Create a basic plug-in. Alternately, you can use Power Platform CLI to create a new project using the command pac plugin init. Use these steps to write a basic plug-in. You need to use Visual Studio to write a plug-in. Download the Plug-in Registration tool by following the instructions here: Dataverse development tools.Knowledge of the Visual C# programming language.If you don't have a model-driven app that includes these, see Build your first model-driven app from scratch for steps to make one in just a few minutes.A model-driven app that includes the account and task tables.Administrator level access to a Microsoft Dataverse environment.We are using this simple example so that we can focus on the process of creating and deploying a plug-in. This goal can be easily achieved using a workflow without writing code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |