Implementing plugin to get/set attribute values of 'Case' entity and create steps in plugin registration tool RRS feed

  • Question

  • Hi,

    I'm newbie in MS Dynamics 365 development and trying to add custom plugins to our On-Promise CRM.

    We need to get values from attributes of Case entity, then send values to an external web service, and finally set attributes value by result of web service methods.

    I have implemented below execution method in plugin using MSDN documents but don't know how to bind Case entity attributes to my method as parameters.

            public void Execute(IServiceProvider serviceProvider)
                //Context = Info passed to the plugin at runtime
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
                IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                //Service = access to data for modification
                IOrganizationService service = factory.CreateOrganizationService(context.UserId);
                // Adding Basic Http Binding and its properties.
                BasicHttpBinding httpBinding = new BasicHttpBinding();
                httpBinding.Name = "HttpBinding_Service";
                httpBinding.Security.Mode = BasicHttpSecurityMode.None;
                httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                httpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                // Endpoint Address defining the asmx Service to be called.
                EndpointAddress endPointAddress = new EndpointAddress(@"webservice url");
                // Call to the Web Service using the Binding and End Point Address.
                SoapClient tcClient = new SoapClient(httpBinding, endPointAddress);
                var entity = (Entity)context.InputParameters["Target"];
                if (entity.LogicalName != "Case")
                var entityId = entity.Id;
                    tcClient.addTicket(/* Sending attributes value as parameters here */);
                catch (Exception)
                    throw new InvalidPluginExecutionException("Failed to register ticket.");

    I also tried to register plug in using Plugin Registration Tool and it has registered successfully.

    But while I try to create steps, I don't know what Message or Primary Entity I have to choose. Case entity does not exists in Primary Entities.

    It would be so appreciated for any help.

    Thank you.

    Saturday, February 8, 2020 8:37 AM