Hi,
I have created a plugin that will trigger on Create and Update, the plugin succeeds which i can see from the system jobs and there is no error but the activity that the plugin is intended to do it not working. I am not even sure how to debug this as there is no error too to use the profiler.
please help.
*This post is locked for comments
HI Nuno,
There is a place in the procedure where i need to have the exception generated stored in a txt file(error details.txt) and use the same, but i actually dont get exceptions at all.
Thanks
Hi,
You do not need any error to use the profiler.
To use the profiler with plugin registration tool you must start profilling a step of your plugin and them execute the action on crm that triggers the step and HERE is generated an exception you may use to debug your plugin. In the links I shared previous it is described the process to debug plugins with plugin registration tool.
Hi Davyjones
You can add loging into your plugin as follows.
1) Create a custom entity with name log
2) Add a custom attribute with the name message.
3) In your plugin just before you start your code (after the service has been created) write these lines of code.
Entity log = new Entity("new_log");
log["new_msg"] = "Log Message";
_service.Create(log);
4) Then you can let's say add another line of your custom code and put these two lines right below that code.
log["new_msg"] = "Log Message 2";
_service.Create(log);
Similarly you can add as much loging into your plugin as you want. Each create statement would insert a record into your log entity.
5) After your plugin has executed go to the advanced find and search log entity.
6) From advanced find you can view all the records and observe the values and see where is the root cause.
I hope this would help you!
Hi Joe,
Apologies, i might be asking the same question again i am very new to this. There is no error in the code at all to catch an exception, i am sying thsi because the plugin is not failing or throwing error at all. i am pasting the code that i am using for your help.
Thanks for your patience.
namespace CRM_to_Finance
{
public class Finance:IPlugin
{
private readonly string _unsecureString;
public Finance(string unsecureString)
{
if (String.IsNullOrWhiteSpace(unsecureString))
{
throw new InvalidOperationException
("Unsecurestring is required by the Plugin, but not provided.");
}
_unsecureString = unsecureString;
}
public void Execute(IServiceProvider serviceProvider)
{
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
Microsoft.Xrm.Sdk.IOrganizationServiceFactory servicefactory = (Microsoft.Xrm.Sdk.IOrganizationServiceFactory)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IOrganizationServiceFactory));
Microsoft.Xrm.Sdk.IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName != "Opportunity")
return;
if (entity.LogicalName == "Opportunity")
{
string oppid;
oppid=entity.Attributes["new_opportunityid"].ToString();
WebClient proxy = new WebClient();
string strurl = "";
strurl = _unsecureString.ToString() + oppid.ToString();
byte[] data = proxy.DownloadData(new Uri(strurl.ToString()));
Stream stream = new MemoryStream(data);
DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(string));
}
}
}
}
}
Hi,
If you read the link I posted it tells you how to add Tracing logs to your code and how to view them
http://joegilldotcom.blogspot.co.uk/2016/07/tracing-in-dynamics-crm-custom.html#more
If your code is not throwing an exception then your cannot capture it to debug. In which you should add the throw statement to your code to force an exception
Joe
Hi Nuno,
Thanks you, but to use the profiler there should be an error, but i am not getting any error at all the plugin just succeeds.
Thanks
Hi Joe,
Thanks for your response, i am not sure how to throw an exception and get it in tracing, all my plugin does is all a webservice appending the opportunity Id .
kindly help
Hi Abdul,
Thanks very much
I strongly believe what you said could be a reason, i am new to these plugins and i am not sure where i should have the above code in my plugin, and where should i go to read the logs. please help.
Hi,
Here you may find out how to debug plugins with plugin registration tool:
www.engagesoftware.com/.../how-to-debug-a-plugin-in-dynamics-crm-2015-online
Additionally, if you're using CRM 2015 update 1 or an earlier version you may use tracelog:
www.magnetismsolutions.com/.../ahmed-anwar&;s-blog/2015/06/04/tracing-and-logging-plugins-in-dynamics-crm-2015-online
Hi,
You could throw an exception in your code to debug it.
Otherwise add tracing statements to help find the problem
joegilldotcom.blogspot.ie/.../tracing-in-dynamics-crm-custom.html
hth
Joe
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156