Hi Dynamicweb,
I am missing an option when creating a new OrderLineField to add the OrderLineField to all groups, so the client does not need to do this manually for all current and future groups.
As a result of this missing option I am trying to subscribe to ApplicationStart event to add it by code, but I receive an "Object reference not set to an instance of an object" in CachedOrderLineFields as the session is not available.
This is my code section in the observer:
public static bool AddField(Group group, string fieldName) { if (!group.OrderLineFields.Any(o => o.SystemName.Equals(fieldName))) { OrderLineField field = OrderLineField.Create(fieldName); if (!string.IsNullOrEmpty(field.SystemName)) { group.OrderLineFields.Add(field); return true; } } return false; }
Can you make a check for the session to exist or make the feature standard in the product?
Best regards, Anders