For a recent project I needed to create and modify the party settings for a specific party through code.
All the ‘basic’ settings like UNA/UNB/Validation/… where rather easy to configure and are pretty straight forward.
However when wanting to configure the UNG segment, we ran into some issues.
But first things first, let’s create a new Party

To modify the EDI properties through code you need to initialize/load a Partner profile as shown below

When you loaded/created the Partner profile it’s rather straight forward to modify the basic Party Settings.

The real problem started when we had to create a UNG segment trough code.
To create a UNG you need to create a PartnerEdifactReceiverGroupUpdatable object and add it to the EdifactReceiver as shown below:

The actual problem here is that the PartnerEdifactReceiverGroupUpdatable class has no constructors defined. Also extending the base class
or implementing the interface did not give us the desired result.
After some investigation we ran into the GetUninitializedObject method from the FormatterServices class (http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatterservices.getuninitializedobject.aspx).
This method will create a new object of a class without calling the constructor, that way we initialized a new instance of PartnerEdifactReceiverGroupUpdatable and managed to create the UNG segment as show below.

Enjoy!
Glenn Colpaert
b8795d2d-a1d6-4cfd-8ad5-61c9395efae3|5|5.0