Developer forum

Forum » Development » Adding OrderLineField to all groups

Adding OrderLineField to all groups

Anders Ebdrup
Reply

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

 


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Yes, TFS#19912 takes the missing session into account.

Votes for this answer: 1
 
Anders Ebdrup
Reply

Thank you so much. Can I find it in the next hotfix for 8.7.0?

 
Anders Ebdrup
Reply

Hi Dynamicweb,

 

I which version will this be fixed?

 

Best regards, Anders

 
Nicolai Høeg Pedersen
Reply

It is currently in the 8.8 branch. It can be merged?

 
Anders Ebdrup
Reply

That would be very nice - thank you :-)

 
Nicolai Høeg Pedersen
Reply

Done, ready for next hotfix

 
Anders Ebdrup
Reply

Hi DW,

 

In which hotfix can I find this change?

 

Best regards, Anders?

 
Nicolai Høeg Pedersen
Reply

It was released with 8.7.2.1

 
Anders Ebdrup
Reply

Thanks, but it seems not to be released yet?

 
Nicolai Høeg Pedersen
Reply

Will be later today - we are just merging and running the tests.

 
Anders Ebdrup
Reply

Hi Nicolai,

 

Thank you!

Next thing is that I can't add the OrderLineFields when a group is saved as all OrderLineFields are removed when saving a group in the administration after the "group saved notification".

Can it be possible to have OrderLineFields added to all new groups? E.g. we are now using this feature to enable giftwrapping for all items on several solutions.

 

Best regards, Anders

 

You must be logged in to post in the forum