Try our conversational search powered by Generative AI!

Calling workflow throws exception in 9.6

Vote:
 

We recently upgraded to 9.6. The project was using the workflows earlier like _carthelper.Cart.RunWorkflow("..").

This is now changed to :

WorkflowResults wr = ServiceLocator.Current.GetInstance().ExecuteActivityFlow(OrderGroupWorkflowManager.CartValidateWorkflowName);

This executes fine, but the result object (WorkflowResults) is filled with exception. And status is "Aborted"

The exception that is thrown is :Validation Error:  Number 278 - 'Property OrderGroup not set.'

Full Stack strace is below:

wr.Exception =

{"Validation Error:  Number 278 - 'Property OrderGroup not set.' \n"}    [Mediachase.Commerce.WorkflowCompatibility.WorkflowValidationFailedException]: {"Validation Error:  Number 278 - 'Property OrderGroup not set.' \n"}    _className: null    _data: null    _dynamicMethods: null    _exceptionMethod: null    _exceptionMethodString: null    _helpURL: null    _HResult: -2146233088    _innerException: null    _ipForWatsonBuckets: 58730441    _message: "Validation Error:  Number 278 - 'Property OrderGroup not set.' \n"    _remoteStackIndex: 0    _remoteStackTraceString: null    _safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}    _source: null    _stackTrace: {sbyte[192]}    _stackTraceString: null    _watsonBuckets: null    _xcode: -532462766    _xptrs: 0    Data: {System.Collections.ListDictionaryInternal}    HelpLink: null    HResult: -2146233088    InnerException: null    IPForWatsonBuckets: 58730441    IsTransient: false    Message: "Validation Error:  Number 278 - 'Property OrderGroup not set.' \n"    RemoteStackTrace: null    Source: "Mediachase.Commerce.Workflow"    StackTrace: "   at Mediachase.Commerce.Workflow.Activities.OrderGroupActivityBase.ValidateRuntime()\r\n   at Mediachase.Commerce.Workflow.Activities.ValidateLineItemsActivity.Execute(ActivityExecutionContext executionContext)\r\n   at Mediachase.Commerce.WorkflowCompatibility.Activity.Execute()\r\n   at Mediachase.Commerce.Engine.ActivityFlowRunner.<>c__DisplayClass1`1.b__0()\r\n   at Mediachase.Commerce.Engine.ActivityFlowRunner.Execute()\r\n   at Mediachase.Commerce.Engine.ExecutionManager.ExecuteActivityFlow(String name, ActivityFlowContext context)"    TargetSite: {Boolean ValidateRuntime()}    WatsonBuckets: nullwr.Exception.StackTrace"   at Mediachase.Commerce.Workflow.Activities.OrderGroupActivityBase.ValidateRuntime()\r\n   at Mediachase.Commerce.Workflow.Activities.ValidateLineItemsActivity.Execute(ActivityExecutionContext executionContext)\r\n   at Mediachase.Commerce.WorkflowCompatibility.Activity.Execute()\r\n   at Mediachase.Commerce.Engine.ActivityFlowRunner.<>c__DisplayClass1`1.b__0()\r\n   at Mediachase.Commerce.Engine.ActivityFlowRunner.Execute()\r\n   at Mediachase.Commerce.Engine.ExecutionManager.ExecuteActivityFlow(String name, ActivityFlowContext context)"

#143305
Jan 19, 2016 22:45
Vote:
 

You need to use the overload with Dictionary<String,Oject> and pass in {"OrderGroup", cart } so it has the correct properties to run the workflow against

#143310
Jan 20, 2016 1:31
Vote:
 

Thanks Mark!

Not sure where to pass that dictionary object, but calling the workflow using OrderGroupWorkflowManager fixed our problem.

So now I would call :

OrderGroupWorkflowManager.RunWorkflow(_carthelper.Cart, "workflowname");

I also had the change the namespace and assembly name in ecf.Workflow.Config file. Doing this the built in workflows worked perfectly!

#143345
Jan 20, 2016 22:54
Vote:
 

You can pass the dictionary by the ActivityFlowContext, something like this:

var context = new ActivityFlowContext(dict);

ServiceLocator.Current.GetInstance<ExecutionManager>().ExecuteActivityFlow(OrderGroupWorkflowManager.CartValidateWorkflowName, context);

You should not need to change the namespace and assembly name in ecf.Workflow.Config 

Regards,

/Q

#143363
Jan 21, 2016 13:57
Vote:
 

Thanks Quan! Will try the context way.

Regarding the ecf.Workflow.Config, you are right. No change there. 

#143381
Jan 21, 2016 16:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.