Try our conversational search powered by Generative AI!

How to add custom property in organization addresses?


How to add custom property in organization addresses?Any one please help me out?

i want add one new property in addresses.

Edited, Oct 27, 2017 11:13

Please refer here  You will want to create a new meta field and then associate that field with OrderAddressEx meta class

Oct 27, 2017 20:19

Thanks mark.

I am adding the customer management->organization -> address via code.

How to assign the values to that custom properties and retrive that also.please help me out.

I am Adding an Customer addresses like below,

Organization org = CustomerContext.Current.GetOrganizationById(orgkey);
var address= CustomerAddress.CreateInstance();
address.AddressType = CustomerAddressTypeEnum.Shipping;

address.RegionCode = wlcOrganizationAddress.AccountId;
address.OrganizationId = org.PrimaryKeyId;

Edited, Oct 28, 2017 11:56
address["FieldName"] = value;

var value = (string)address["FieldName"]

var value = address.GetStringValue("FieldName");
Edited, Oct 31, 2017 17:29

Thank you Mark,

Already i tried this code.If i use this "address["FieldName"] = value;" the custom property value is added into Extended properties but i dont think the value saved into database.If i tried to retrive the value is empty only.

Nov 01, 2017 8:45

Have you saved the customer contact after you added it?

Nov 01, 2017 13:53

Hi Erik,

I have saved using this funtion "BusinessManager.Create(address);" all the other default properties are saved only the custom properties not saved.

Nov 02, 2017 8:24

Can you check if DefaultMetaObjectFactory.CanCreate returns true for your metaclass?

Nov 02, 2017 13:45

Also do try and create it first, then add you custom properties and save it again.

Default properties isn't stored in the same array and it is even stored on a base class so it isn't the same code that handles them.

Nov 02, 2017 14:12

Hi Erik,

Thank you.

I made one mistake in adding meta field for now i added meta field using code and saved my custom property like above code (#184489).

private void SetupMetaField()
MetaClassManager metaModel = DataContext.Current.MetaModel;
foreach (MetaClass metaclasses in metaModel.MetaClasses)
if (metaclasses.Name == "Address")
string fieldName = "meta field name";
if (metaclasses.Fields[fieldName] == null)
AttributeCollection attr = new AttributeCollection();
MetaField newMetafield = metaclasses.CreateMetaField(
"meta field name",

if there any way to add meta field to customer management address using commerce backend.

please inform me.

Nov 04, 2017 11:24

commerce backend as in the commerce manager administration UI?

Commerce->Commerce Manager->Administration->System settings->Business Foundation

The "Address" object contains the definitions for all those meta fields, if it can be done it is there.

On a side note your above code is more complex than needed, to retrieve and create a field on address you can do something similar to this:

var metaClass = DataContext.Current.GetMetaClass("Address");

using (var myMetaBuilder = new MetaFieldBuilder(metaClass))
    myMetaBuilder.MetaClass.AccessLevel = AccessLevel.Customization;
    myMetaBuilder.CreateText("meta field name",
                             "meta field friendly name",
Edited, Nov 06, 2017 15:57
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.