locked
Fire order fulfill in plugin RRS feed

  • Question

  • I'm doing a plugin for MS CRM 4 which sends emails when order is created or order is fulfilled. I'm firing create of order by registering my plugin in Plugin registration tool to messagename = create and primary entity name = order. But I can not fire when order is fulfilled. I have tried SetStateDynamicEntity, SetState, Update and other Message names but noone is firing this event.

    Can you please help me. How can I fire order fulfill event in plugin??

    I can't use workflow, only plugin...

    thanx in advanced
    Friday, February 19, 2010 9:33 AM

Answers

All replies

  • Hi.

    Check this url .
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)free countersLocations of visitors to this page
    • Marked as answer by cHORPO Friday, February 19, 2010 10:16 AM
    Friday, February 19, 2010 9:39 AM
    Moderator
  • I have IsCustomeStepAllowed set to true. But I have got below error message.

    I use there ICrmService service = context.CreateCrmService(false);

    how to call CreateCrmService from Child pipeline and also how to detect that I'm in child pipeline???


    Microsoft CRM Error Report:
    Error Description:
    Only SdkMessageProcessingStep in parent pipeline and in stages outside transaction can create CrmService to prevent deadlock.

    Error Details:
    Only SdkMessageProcessingStep in parent pipeline and in stages outside transaction can create CrmService to prevent deadlock.

    Full Stack:
    [CrmException: Only SdkMessageProcessingStep in parent pipeline and in stages outside transaction can create CrmService to prevent deadlock.]
    at Microsoft.Crm.Extensibility.PipelineExecutionContext.CreateCrmService(Boolean useCurrentUserId)
    at CrmPlugin.PreNotifyPlugin.Execute(IPluginExecutionContext context) in PreNotifyPlugin.cs:line 72
    at Microsoft.Crm.Extensibility.PluginStep.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.Execute(PipelineExecutionContext pluginContext)
    at Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.Update(BusinessEntity entity, FilterExpression filter, ExecutionContext context)
    at Microsoft.Crm.BusinessEntities.BusinessProcessObject.Update(IBusinessEntity entity, ExecutionContext context)
    at Microsoft.Crm.ObjectModel.QOIService.Update(IBusinessEntity qoi, IBusinessEntity qoiPreImage, ExecutionContext context, Boolean calculatePrice)
    at Microsoft.Crm.ObjectModel.SalesOrderService.Update(IBusinessEntity salesOrder, ExecutionContext context)
    at Microsoft.Crm.ObjectModel.SalesOrderService.Fulfill(OrderClose orderClose, Int32 status, ExecutionContext context)

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
    at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IPluginExecutionContext context)
    at Microsoft.Crm.Extensibility.PluginStep.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
    at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.RequestBase.Process(Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.RequestBase.Process(CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.CrmServiceInternal.Execute(RequestBase request, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.InProcessCrmService.Execute(Object request)
    at Microsoft.Crm.Application.Platform.ServiceCommands.PlatformCommand.ExecuteInternal()
    at Microsoft.Crm.Application.Platform.SalesOrder.Fulfill(Int32 newStatus, String fulfillDate, String description)
    at Microsoft.Crm.Web.SFA.SalesOrderDetailPage.closeOrder(Object sender, DataEventArgs e)
    at Microsoft.Crm.Application.Forms.DataEventProcessor.Raise(FormEventId eventId, FormState state, IUser user, String objectId, Entity entity)
    at Microsoft.Crm.Application.Forms.AppForm.RaiseDataEvent(FormEventId eventId)
    at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity)
    at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, String formType)
    at Microsoft.Crm.Web.SFA.SalesOrderDetailPage.ConfigureForm()
    at Microsoft.Crm.Application.Controls.AppUIPage.OnPreRender(EventArgs e)
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
    at System.Web.UI.Page.HandleError(Exception e)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at ASP.gemax_sfa_salesorder_edit_aspx.ProcessRequest(HttpContext context)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


    Other Message:
    Error Number:
    0x80044186

    Source File:
    Not available

    Line Number:
    Not available

    Friday, February 19, 2010 10:00 AM
  • Try to use following code to create CrmWebService instance:

                CrmAuthenticationToken token = new CrmAuthenticationToken();
                token.AuthenticationType = AuthenticationType.AD;
                token.OrganizationName = <Your organization name>;
    
                CrmService crmService = new CrmService();
                crmService.UseDefaultCredentials = true;
                crmService.Url = (string)(Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\MSCRM").GetValue("ServerUrl")) + "/2007/crmservice.asmx";
                crmService.CrmAuthenticationTokenValue = token;
    
    If context.InvocationSource equals 0 - this is parent pipeline, 1 - child.


    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный) free counters Locations of visitors to this page
    Friday, February 19, 2010 10:04 AM
    Moderator
  • That did the trick. Thank you for your responses
    Friday, February 19, 2010 10:17 AM