Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

CRM 2013: Passing Account Info into Webservice via Plugin

$
0
0

We are using CRM 2013. I'm trying to create a plugin that triggers when a CRM Account is created. Then the plugin will fires and sends an attribute 'AccountNumber' into an external webservice. However the webservice does not seem to get called whatsoever now.

At first I thought I had to do a PostImage, but then decided not to use it anymore. Also at first I was using "EntityMoniker" as a plugin parameter but then corrected it to type "Target".

Here's my code:

I'm wondering if probably the plugin is never triggered at all. Is there a way to check whether a plugin gets triggered or not?

Could someone please guide me in the right direction?

Thanks in advanced for your help.

var trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

            // The InputParameters collection contains all the data passed in the message request.
            var targetEntity = context.GetParameterCollection<Entity>(context.InputParameters, "Target");

            if (targetEntity == null)
                throw new InvalidPluginExecutionException(OperationStatus.Failed, "Target Entity cannot be null");

            // Make sure the new Case Id is available
            if (!context.OutputParameters.Contains("id"))
                return;

            var accountID = new Guid(context.OutputParameters["id"].ToString());

            var postImage = context.PostEntityImages["PostImage"];

            if (postImage == null)
                throw new InvalidPluginExecutionException(OperationStatus.Failed, "Post Image is required");

            var accountNo = targetEntity.Attributes["new_accountnumber"].ToString();

            var service = new PropertyServiceClient("");

            var newProp = new PropertySetup
            {
                _prop = new GProperty
                {
                    _propertyNm = accountNo
                }
            };

            service.CreateNewGProperty(newProp);
            service.Close();



Viewing all articles
Browse latest Browse all 1000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>