locked
ISV Code aborted the operation - salesorderdetail plugin RRS feed

  • Question

  • I want to be able to stop the creation of a salesorderdetail (Order Product) record on an Order when there is no stock available.

    I have a plugin registered on pre operation create that checks the stock level and throws an Exception if there is not enough stock, however the error message is not being surfaced up to the user - instead, I just get a little red X that I have to hover over to see the message "ISV Code aborted the operation".

    Is there a way to actually surface the error message that is being thrown rather than this generic error..

    I have tested this with a plugin running on Delete of salesorderdetail and I get the proper Business Process Error dialog when the plugin throws an error..


    • Edited by blpr Wednesday, March 15, 2017 8:53 PM typo
    Wednesday, March 15, 2017 4:18 AM

All replies

  • Hi,

    You get this "ISV Code aborted the operation" because there is a bug in your code. your plugin errors before you throw your exception. Re-check your code or enable tracing and see where the error occur.

    Thanks


    Sachith Chandrasiri

    Wednesday, March 15, 2017 5:10 AM
  • Thanks Sachinth,

    I have confirmed in the plugin trace that my exception is the one being thrown. I've also tested on a new instance of 365 with a simple plugin that just throws an exception and experienced the same result..

    Wednesday, March 15, 2017 8:52 PM
  • Hi,

    Can you share your code please?

    Thanks


    Sachith Chandrasiri

    Wednesday, March 15, 2017 10:28 PM
  • I wrote this test plugin which just throws an exception and registered on pre-op update of salesorderdetail

    using System;
    using System.ServiceModel;
    using Microsoft.Xrm.Sdk;
    
    namespace BasicPlugin
    {
        public class Plugin : IPlugin
        {
            internal IServiceProvider ServiceProvider { get; set; }
            internal IOrganizationService OrganizationService { get; set; }
            internal IPluginExecutionContext PluginExecutionContext { get; set; }
            internal IServiceEndpointNotificationService NotificationService { get; set; }
            internal ITracingService TracingService { get; private set; }
    
            public void Execute(IServiceProvider serviceProvider)
            {
                // Obtain the execution context service from the service provider.
                this.PluginExecutionContext = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    
                // Obtain the tracing service from the service provider.
                this.TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
    
                // Obtain the Organization Service factory service from the service provider
                IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    
                // Use the factory to generate the Organization Service.
                OrganizationService = factory.CreateOrganizationService(PluginExecutionContext.UserId);
    
                throw new InvalidPluginExecutionException("Testing Sales Order Detail Exception!");
            }
        }
    }

    Thursday, March 16, 2017 12:59 AM
  • Hi,

    I used your code and I am getting the expected error message. See the screen shot below. Are you sure there are no any other plugins or sync workflows on this entity in your environment?

    Thanks


    Sachith Chandrasiri

    Thursday, March 16, 2017 1:14 AM
  • Thanks Sachith,

    I'm seeing the problem when I try to add a new product via the products subgrid on the order form.

    Thursday, March 16, 2017 2:22 AM
  • I suppose this is how the subgrid shows errors; instead of displaying the details it simply says that an error occured.

    Thanks


    Sachith Chandrasiri

    Thursday, March 16, 2017 3:22 AM