Answered by:
Question on Generic SQL Error with calling a web service

Question
-
In a post operation update on the Incident Entity, I call a WCF Service that queries back at CRM to do create some records of another entity with the results from the LINQ query.
I pass the Guid of the incident to the WCF Service that is used for part of the "where" clause.
When I call the WCF Service from a test client or form in the same project I can successfully execute the service method. When I call the same method from the plugin with the same guid,
I receive a Generic SQL Error message. However, as soon as I make the plugin Asynchrous the service method works fine.
Is there something in the context of the post operation event that is causing SQL to lock up ? If I take that guid and hard code it in the service function and then call the service from within the plugin it will work as well.
So an exception occurs when I pass the guid from the plugin but if I hardcode the guid in the Service it works fine.
Any suggestions what causes this for a synchronous post operation but not asynchronous ? I have not run profiler but am guessing something is locking up ?
Thanks,
Tuesday, May 15, 2012 12:04 AM
Answers
-
Hi,
In my case I had locking on the record status field. I had converted the logic to a workflow and had the job done there.
In your case, you can use the async plugin.
What you can do is to rearranging the code. Try creating the records first.
I hope this helps. If my responses answered your question, please mark these responses as an answer and also vote them as helpful.
Ashish Mahajan, CRM Developer, CSG (Melbourne)
My Personal Website: http://www.ashishmahajan.com
My Blogs: http://ashishmahajancrm.blogspot.com.au and http://ashishmahajancrm.wordpress.com
My Youtube Channel: http://www.youtube.com/user/ashishmahajanmscrmMy Linkedin: - Proposed as answer by Ashish Mahajan Technical Architect, Writer Tuesday, May 15, 2012 2:18 AM
- Marked as answer by MRUNKS Tuesday, May 15, 2012 1:49 PM
Tuesday, May 15, 2012 2:18 AM
All replies
-
Hi,
Yes, you are right, there is high probability of locking.
I had a similar issue in my previous projects. I had to tweak the code to make it work synchronously.
Do you actually want to execute this synchronously? I mean if you execute this asynchronously, then the user will not have to wait for the process to get over. Is there a requirement of running it immediately. I agree, with async the records will not be created instantaneously, but if the user can get away with it, then go for async.
I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
Ashish Mahajan, CRM Developer, CSG (Melbourne)
My Personal Website: http://www.ashishmahajan.com
My Blogs: http://ashishmahajancrm.blogspot.com.au and http://ashishmahajancrm.wordpress.com
My Youtube Channel: http://www.youtube.com/user/ashishmahajanmscrmMy Linkedin: - Proposed as answer by Ashish Mahajan Technical Architect, Writer Tuesday, May 15, 2012 1:48 AM
Tuesday, May 15, 2012 1:48 AM -
We can live with async, I'm just curious as to the underlying reason/cause to why it happens? What I don't like in making it async for this project is that I will need an additional plugin that will fire post operation but async while I have the existing one still fire synchronously for the other code that already exists and needs to fire in sync.
Thanks,
Tuesday, May 15, 2012 2:11 AM -
Hi,
In my case I had locking on the record status field. I had converted the logic to a workflow and had the job done there.
In your case, you can use the async plugin.
What you can do is to rearranging the code. Try creating the records first.
I hope this helps. If my responses answered your question, please mark these responses as an answer and also vote them as helpful.
Ashish Mahajan, CRM Developer, CSG (Melbourne)
My Personal Website: http://www.ashishmahajan.com
My Blogs: http://ashishmahajancrm.blogspot.com.au and http://ashishmahajancrm.wordpress.com
My Youtube Channel: http://www.youtube.com/user/ashishmahajanmscrmMy Linkedin: - Proposed as answer by Ashish Mahajan Technical Architect, Writer Tuesday, May 15, 2012 2:18 AM
- Marked as answer by MRUNKS Tuesday, May 15, 2012 1:49 PM
Tuesday, May 15, 2012 2:18 AM -
Thanks, unfortunately the event has to fire on the update post operation rather than the post create. For now I am going to make a separate plugin that will be asynchronous and have it fire before the other post update plugin event.Tuesday, May 15, 2012 1:49 PM