Transaction Aborted

We created a data directive that would amend an order, using the SalesOrderSvcContract. Now it was quite complex and started giving a transaction aborted error. So reduced the code to the simplest that I could that still gave the error, which is below, anyone else have this issue and worked out a solution?

using (Erp.Contracts.SalesOrderSvcContract soSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
    int orderNum = 1008400;

    try
    {
      var salesOrderTS = new Erp.Tablesets.SalesOrderTableset();
      salesOrderTS = soSvc.GetByID(orderNum);

      var ttOrderHedR = salesOrderTS.OrderHed.FirstOrDefault(x => x.Company.Equals(Session.CompanyID));
           

      ttOrderHedR["OrderType_c"] = "";
      ttOrderHedR.RowMod = "U";

      soSvc.Update(ref salesOrderTS);

    }

    catch (Exception ex)
    {
        this.PublishInfoMessage("Error : " + ex.Message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
    }

}

I tried your exact code in our sandbox. We also have that UD field. It worked for me.

Before:
image

After updating a record the DD was tied to:
image

What DD are you firing this from? And is it In-Transaction or Standard?

Thanks,

It is an In-Transaction directive on the SysAgentSched (checking for the next run having been changed)

My thought is maybe the CompanyID isn’t what you think it is on this. Have you tried seeing what that value is? What happens if you hard code it?

Thanks, I will give that a try.

I’m assuming you might be multi company. If not, this may not be the cause. If you are, then hard coding the company may not work if what is firing the data directive is not in the same company as the order.