web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting error while fulfill the order through code activity

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Oleksandr Klymenko Profile Picture
    40 on at
    RE: Getting error while fulfill the order through code activity

    Are you sure there is at least one record with name MSDN and orderdata is not empty? Try to perform a check before fulfilling the order

  • Community Member Profile Picture
    on at
    RE: Getting error while fulfill the order through code activity

    Desired record is available @Oleksandr

    When i try to convert from  fulfill to active, it works fine. But when try to fulfill from active above mention issue exists.

    I don't know why this error prompts.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans