Hi All,
i am getting error message while trying to fulfill the active order using workflow.
Below is my code
protected override void Execute(CodeActivityContext executionContext)
{
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
dbContext _context = new dbContext(service);
try
{
var orderdata = _context.SalesOrderSet.Where(s => s.Name.Contains("MSDN")).FirstOrDefault();
int newStatus = (int)salesorder_statuscode.Complete;
var requestss = new FulfillSalesOrderRequest
{
OrderClose = new OrderClose
{
SalesOrderId = new EntityReference { LogicalName = SalesOrder.
EntityLogicalName, Id = orderdata.SalesOrderId.Value }
},
Status = new OptionSetValue(newStatus)
};
service.Execute(requestss);
}
catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
{
tracingService.Trace("Error reason " + ex.Message);
throw ex;
}
}
I am getting the below error
"
An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics 365 Community for solutions or contact your organization's Microsoft Dynamics 365 Administrator. Finally, you can contact Microsoft Support" |
Plugin Trace:
[FullFilOrderTest: FullFilOrderTest.OrderTest]
[FullFilOrderTest (1.0.0.0): FullFilOrderTest.OrderTest]
Error reason An unexpected error occurred.
Error Message:
Unhandled Exception: Microsoft.Crm.CrmException: An unexpected error occurred.
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)
*This post is locked for comments