On MS Dynamics CRM Online 2015 Update 1- I have deployed a plugin and it throws Generic SQL Error exception. The tracing log is not showing anything missing from steps I need to perform. Everything is smooth in logs. The error is as:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Generic SQL error.Detail: <OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts"> <ErrorCode>-2147204784</ErrorCode> <ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" /> <Message>Generic SQL error.</Message> <Timestamp>2015-09-14T12:41:05.6044674Z</Timestamp> <InnerFault i:nil="true" /> <TraceText i:nil="true" /></OrganizationServiceFault>
I appreciate all the help.
Refer this blog:
If possible try to test your code by writing a console application and see if you are getting the same error. Also you could try to re-register steps and plugin, If not resolved you may need to work with Microsoft Support (if you are working for Microsoft Partner, you will get free advisory hours that you can use for this) because this is a very generic error and there could be many reason for this.
Hope it will help.
thanks for your response. I have tried that as well, the tracing shows all the steps are being processed successfully. I think the error is thrown by service.Update method. As, in my tracing there is no error record either.
In addition to exceeding the max length of an attribute and attempting to set a lookup to a record that doesn't exist as mentioned in the link Rajkumar provided, a generic SQL error will be thrown if you call the Create method on the organization service with an entity that already exists (e.g. duplicate key error). Would probably help to post the code you think is causing the exception.
Thanks all for responding on my query.
my points are as:
I dont have any duplicate key values.
The weird thing is same code does work on Update method.
My entity does not have any mandatory lookups to be filled before Create call
Code just pulls a Unique format of strings from one entity and does some calculation on main entity to update the field on form.
Hope this helps.
I believe what you're saying is that you have a plugin registered for the Pre Create and Pre Update message of an entity and that plugin does a calculation and sets a field on the record.
If that is the case and you are attempting to update the record using the Update method on the Organization Service then that is the source of your error.
In the Pre stage of the plugin the record has not yet been persisted so calling update would fail in Pre Create. The correct way to update the record involved in the transaction is to simply set the attribute you want to update on the Pre Entity Image in the plugin. CRM will see the change you made in the plugin and persist the new value for you in the main stage of the execution pipeline.
Dear Michael Ochs,
Many thanks for your consideration. Actually, my Create method got following parameters:
Pipeline Stage: Post
My UPDATE method triggers the plugin without any error and updates the field correctly, whilst the CREATE does not work and throws an error.
TRACE sequence of code does not show any error and have the right values.
I have managed to fix the issue, the following steps I have taken:
1- service.Update(app); method is removed instead calling the
2- entity.Attributes.Add("abc_name", newValue);
3- Register the plugin in Pre-Operation mode
Business Applications communities