November Happy Hour will be moved to Thursday December 5th.

Organization on OrderGroup

Vote:
 

Hi all,

We are currently building a commerce website and are using the Serializable Cart. I am trying to register the Id of the organization of a contact on the cart. I found a property on the cart "Organization", type nullable Guid. Looks great...

However after saving the ICart as PurchaseOrder: orderRepository.SaveAsPurchaseOrder(cart), the organizationId is nowhere to be found on the PurchaseOrder.
After some decompiling I found out that the SaveAsPurchaseOrder copies the Organization property from the cart to the purchase order.
Which eventually results in calling the setter on the Mediachase.Commerce.Orders.OrderGroup class. This property contains the following code:

Guid? IOrderGroup.Organization
    {
      get
      {
        if (string.IsNullOrEmpty(this.OwnerOrg))
          return new Guid?();
        Guid result;
        return Guid.TryParse(this.OwnerOrg, out result) ? new Guid?(result) : new Guid?();
      }
      set
      {
        if (value.HasValue)
          this.OwnerOrg = value.ToString();
        this.OwnerOrg = (string) null;
      }
    }

I do not get the last line: setting the property to null again ...

Any ideas why, or how to store the current contact organizationId on the cart and propagating it to the PurchaseOrder?

#224757
Jun 25, 2020 10:07
Vote:
 

I think that is a bug it should return after setting the value if the if statement.  You can try setting the PurchaseOrder.OwnerOrg field directly after converting.

#224910
Jun 29, 2020 20:39
Vote:
 

Yeah, I did that.

Looks to me like the "else" is missing.

So code should probably look something like:

if (value.HasValue)
{
    this.OwnerOrg = value.ToString();
}
else
{
    this.OwnerOrg = (string) null;
}

Any ideas when this will be fixed?

#225718
Jul 24, 2020 6:43
Vote:
 

I've experienced the same bug.

So I had to cast the IPurchaseOrder in-line to set the OwnerOrg property, because my OrganizationId value was not stored.

#225719
Jul 24, 2020 7:41
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.