SBX - Search With Button

SBX - Forum Post Title

Plugin error - Generic SQL Error

Microsoft Dynamics CRM Forum

Osman asked a question on 14 Sep 2015 7:53 AM
My Badges

Question Status

Verified

Hi,

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=7.0.0.0, 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.

Many thanks,

Reply
Mahender responded on 14 Sep 2015 8:12 AM
My Badges

Hello,

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.

Reply
Osman responded on 14 Sep 2015 8:17 AM
My Badges

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.

Reply
Michael Ochs responded on 14 Sep 2015 11:30 AM
My Badges

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.

Reply
Osman responded on 14 Sep 2015 11:59 AM
My Badges

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.

Many thanks,

Reply
Michael Ochs responded on 14 Sep 2015 12:30 PM
My Badges
Suggested Answer

Osman,

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.

Reply
Osman responded on 14 Sep 2015 12:52 PM
My Badges
Verified Answer

Dear Michael Ochs,

Many thanks for your consideration. Actually, my Create method got following parameters:

Pipeline Stage: Post

Execution:Synchronous

Deployment: Server

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.

Thanks,

Osman

Reply
Osman responded on 15 Sep 2015 5:20 AM
My Badges
Verified Answer

Hello All,

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

Thanks all,

Reply
Osman responded on 14 Sep 2015 12:52 PM
My Badges
Verified Answer

Dear Michael Ochs,

Many thanks for your consideration. Actually, my Create method got following parameters:

Pipeline Stage: Post

Execution:Synchronous

Deployment: Server

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.

Thanks,

Osman

Reply
Osman responded on 15 Sep 2015 5:20 AM
My Badges
Verified Answer

Hello All,

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

Thanks all,

Reply
Michael Ochs responded on 14 Sep 2015 12:30 PM
My Badges
Suggested Answer

Osman,

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.

Reply

SBX - Two Col Forum

SBX - Migrated JS