Has anyone been able to reopen a closed order release and modify it in the OrderRel table from an external program (VB.NET or C#)?
I've tried calling the SalesOrder BO's ReopenOrder method, then the ReopenOrderLine method and the ReopenRelease method in succession and then write to the table, but when I call the OrderRelSearch BO's Update method to commit the changes, I get an exception that says "Update of Order Release not allowed."
Has any one overcome this?
Any insight would be greatly appreciated.
Here is my code if anyone is interested (C#, heavily commented so its easy to follow):
private void writeToEpicor(DataTable dt)
{
// Establish a session in Epicor.
using (Epicor.Mfg.Core.Session myEpiSession = new Epicor.Mfg.Core.Session(epiSessionName, epiSessionPassword, epiSessionAppServer))
{
// For each row in a datatable I got back from from a SQL query.
for (int i = 0; i < dt.Rows.Count; i++)
{
try
{
// Instantiate an object of the SalesOrder class.
Epicor.Mfg.BO.SalesOrder salesOrderSession = new Epicor.Mfg.BO.SalesOrder(myEpiSession.ConnectionPool);
// Reopen the Order, the orderline, and the orderrelease.
salesOrderSession.ReopenOrder(Convert.ToInt32(dt.Rows[i]["OrderNum"]));
salesOrderSession.ReopenOrderLine(Convert.ToInt32(dt.Rows[i]["OrderNum"]), Convert.ToInt32(dt.Rows[i]["OrderLine"]));
salesOrderSession.ReopenRelease(Convert.ToInt32(dt.Rows[i]["OrderNum"]), Convert.ToInt32(dt.Rows[i]["OrderLine"]), Convert.ToInt32(dt.Rows[i]["OrderRelNum"]));
// Instantiate an object of the OrderRelSearch class.
Epicor.Mfg.BO.OrderRelSearch orderRelSession = new Epicor.Mfg.BO.OrderRelSearch(myEpiSession.ConnectionPool);
// Get the order I've reopened.
Epicor.Mfg.BO.OrderRelSearchDataSet orderRelDataSet = orderRelSession.GetByID(Convert.ToInt32(dt.Rows[i]["OrderNum"]), Convert.ToInt32(dt.Rows[i]["OrderLine"]), Convert.ToInt32(dt.Rows[i]["OrderRelNum"]));
// Modify the record.
orderRelDataSet.OrderRel[0].Date07 = DateTime.Parse(results[0]);
orderRelDataSet.OrderRel[0].Date08 = DateTime.Parse(results[1]);
orderRelDataSet.OrderRel[0].RowMod = "U";
// Commit the changes to the database.
try
{
orderRelSession.Update(orderRelDataSet);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// Reclose the order, the orderline and the orderrelease.
salesOrderSession.CloseOrder(Convert.ToInt32(dt.Rows[i]["OrderNum"]));
salesOrderSession.CloseOrderLine(Convert.ToInt32(dt.Rows[i]["OrderNum"]), Convert.ToInt32(dt.Rows[i]["OrderLine"]));
salesOrderSession.CloseRelease(Convert.ToInt32(dt.Rows[i]["OrderNum"]), Convert.ToInt32(dt.Rows[i]["OrderLine"]), Convert.ToInt32(dt.Rows[i]["OrderRelNum"]));
}
catch
{
continue;
}
}
}
}