order.SetValuesFromCarrier shows error in Log

I created a scheduled task to remove personal info from the order, using below code

foreach (var order in orders)
 {
var orderCarrier = order.GetAsCarrier(false, true, false, false, false, true);

orderCarrier.CustomerInfo.Address.ClearPersonalData();
orderCarrier.Deliveries[0].Address.ClearPersonalData();
orderCarrier.PaymentInfo[0].BillingAddress.ClearPersonalData();

order.SetValuesFromCarrier(orderCarrier, ModuleECommerce.Instance.AdminToken);
 }



  public static void ClearPersonalData(this AddressCarrier addressCarrier)
  {
if (addressCarrier == null) throw new ArgumentNullException("addressCarrier");

var emptyAddress = new AddressCarrier
{
	FirstName = string.Empty,
	LastName = string.Empty,
	Address1 = string.Empty,
	Address2 = string.Empty,
	Zip = addressCarrier.Zip,
	City = addressCarrier.City,
	Country = addressCarrier.Country
};

addressCarrier.SetValues(emptyAddress, addressCarrier.ID);
 }

This code is working as expected - it clearing user information form the order. But in the log it showing exceptions as below

I think this is a bug in the platform, I can reproduce the same error if I create and edit an order directly from back office. Could you report it on Docs?

It seems like the db trigger for when an address is updated joins a bit too freely, so we end up with NULL as order id in the event table. Then when the event is processed it throws the exception.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.