Hi All. Sometimes we come across certain situations where we need to Fulfill an Order by our code of Plugin or Workflow. Here I am going to explain you a step by step way to Fulfill an Order via C# code in Microsoft Dynamics CRM.
Step1:
Get the GUID of the Order record which you want to fulfill. Lets say "orderGuid".
Step2:
Get the optionset value of the "Status" which fulfills the Order. In my case it is 100001(Fulfill).
Step3:
Add the reference "Microsoft.Crm.Sdk.Messages" to your code.
"using Microsoft.Crm.Sdk.Messages;"
Step4:
Add the below code:
FulfillSalesOrderRequest req = new FulfillSalesOrderRequest();
req.OrderClose = new Entity("orderclose");
req.OrderClose["salesorderid"] = new EntityReference("salesorder", orderGuid);
req.Status = new OptionSetValue(100001); //Fulfill = 100001
localContext.Trace("before executing");
FulfillSalesOrderResponse resp = (FulfillSalesOrderResponse)localContext.OrganizationService.Execute(req);
localContext.Trace("after executing");
When this code gets executed, the Order will get fufilled and will become readonly.
For more info Click Here







