Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM 2013 plugin CRUD operation error while calling IOrganizationService

Posted on by 5

Hi,

 I tried to understand how CRM 2013 plugin works but I face some issues with IOrganizationService in Plugin.

IPluginExecutionContext context = (IPluginExecutionContext) serviceProvider.GetService(typeof(IPluginExecutionContext));

IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
var serviceContext = new OrganizationServiceContext(service);

QueryExpression accountQuery = new QueryExpression("account");
accountQuery.ColumnSet = new ColumnSet(true);
EntityCollection _entityCollection = (EntityCollection)service.RetrieveMultiple(accountQuery);

So it should return data to my _entityCollection object, but it throws the exception:  <Message>An event was requested after the recorded event queue has been completed.</Message>.

I have no idea what does it mean and there is not much useful information on internet so just want to know where I did wrong.

this assembly has been registered in both sandbox and none and it didn't work.

Thanks!

*This post is locked for comments

  • CCLEE Profile Picture
    CCLEE 5 on at
    RE: CRM 2013 plugin CRUD operation error while calling IOrganizationService

    Updates.

    Plugin Profiler doesn't work with Retrieve and RetrieveMultiple on CRM 2013 SDK. It's definitely a bug and it wasted my 2 days on guess what's going on.

    If you are wondering why it keeps throwing weird error messages while using profiler even though you only have a super simple implementation, stop use profiler and just go ahead and throw an exception with the message of _entityCollection.Entities.Count. You will know what's going on.

  • CCLEE Profile Picture
    CCLEE 5 on at
    RE: CRM 2013 plugin CRUD operation error while calling IOrganizationService

    Thank you so much for your reply.

    I guess the issue is that there is a EventQueue Object under OrganizationService. If I want to do CRUD operation I need to make sure that the same operation is recorded in eventQueue. In my case, the eventQueue was empty (count = 0) so that the application assumed I completed all the operations and throw the exception (An event was requested after the recorded event queue has been completed.). 

    I didn't expect that the CRM plugin development can be this tricky. Gosh. I have no idea how to record the right event now.

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: CRM 2013 plugin CRUD operation error while calling IOrganizationService

    Hi,

     looks like it's not so much a plugin error - it's a plugin profiler error. No idea why it's happening, though(try another version of the plugin registration tool? Maybe download 2015 SDK - there were some issues in 2013.. not specifically with the plugin profiler, though).. you might try other ways to debug, too (Visual Studio maybe. Especially if you can get CRM installed on your dev workstation)

  • CCLEE Profile Picture
    CCLEE 5 on at
    RE: CRM 2013 plugin CRUD operation error while calling IOrganizationService

    There is the exception message.

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An event was requested after the recorded event queue has been completed.

    Detail: <OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts&quot; xmlns:i="www.w3.org/.../XMLSchema-instance&quot;>

     <ErrorCode>-2147220970</ErrorCode>

     <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic&quot;>

       <KeyValuePairOfstringanyType>

         <a:key>CallStack</a:key>

         <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema&quot;>   at PluginProfiler.Library.ProfilerReplayService`1.NextEvent()

      at PluginProfiler.Library.ProfilerReplayOrganizationService.NextReturnValue[TClientOperation,TResult](ProfilerOrganizationServiceClientOperation operation, Object[] inputParameters)

      at Microsoft.Crm.Sdk.Samples.AccountNumberPlugin.Execute(IServiceProvider serviceProvider)

      at PluginProfiler.Library.PluginAppDomainProxy.ExecuteCore(Stopwatch watch, ProfilerExecutionReport report, Object instance, Object executionParameter)

      at PluginProfiler.Library.AppDomainProxy.Execute(ProfilerExecutionConfiguration configuration, ProfilerExecutionReport report)</a:value>

       </KeyValuePairOfstringanyType>

     </ErrorDetails>

     <Message>An event was requested after the recorded event queue has been completed.</Message>

     <Timestamp>2018-04-24T23:57:12.8940123Z</Timestamp>

     <InnerFault i:nil="true" />

     <TraceText i:nil="true" />

    </OrganizationServiceFault>

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans