Skip to main content

Notifications

Announcements

No record found.

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 Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee 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.

  • 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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans