I would be grateful for guidance and code samples to assist with a piece of automation.
A number of our sales orders have specialist transportation requirements, we are querying the status of the deliveries via API’s.
I have written a function that runs a baq to extract the relevant open sales orders, and in turn, queries the status of the delivery via the published API’s. This function will run every few hours. This part of the code is working well.
The issue that I have is that I would like to write the status of the delivery in a UD field stored on the order header. Could anyone direct me to available c# code that will perform this task?
You’ll want to add the Erp.BO.SalesOrderSvc to your References under the Services tab. You then can use something like this:
CallService<Erp.Contracts.SalesOrderSvcContract> ( svc => {
var OrderTableset = svc.GetByID( orderNumber ); // OrderNum from your query
var orderHedRow = OrderTableset.OrderHed.FirstOrDefault();
orderHedRow.DeliveryStatus_c = retrievedDeliveryStatus; // Status from your API response
orderHedRow.RowMod = "U"; // Setting rowmod to U (Updated) tells the service that you want this row to save changes
svc.Update( ref OrderTableset ); // Saves the update to your custom field.
});
Thank you for the response - that was incredibly helpful. I can use this code to set values that are native to the OrderHed table - for example OrderComment however, when I attempt to set any UD field an error is thrown when checking syntax.
OrderHedRow does not contain a definition for PaymentStatus_c..