Developer forum

Forum » Development » User custom fields

User custom fields

Emil Højbjerg
Reply
Hi,

Is adding customfields to users supported in the API - and if so, where?

Thanks :-)!


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Emil

Yes, it's possible. You need to use the CustomField class in order to do it.

// Creates a new CustomField object.
// "systemname" is the SystemName of the field. This value must conform to the same rules as a column name in the database.
// "tablename" is the name of the table in which to create the CustomField. In this case it's "AccessUser".
// type is the type of the CustomField. This value is of type Dynamicweb.Modules.Common.CustomFields.CustomFieldType.Types.
var cf = new Dynamicweb.Modules.Common.CustomFields.CustomField("systemname", "tablename", type);
cf.Name = "Name of the field"; // This is used as the label in the UserManagement module
cf.Database = "Access.mdb"; // Defines which system databse to use. This is only relevant for solutions using MS Access.
cf.Save();

If you create a field of type RadioButtonGroup or DropDown then you will also have to create some options. Use the property "Options" on the CustomField object.

Hope this helps :)

- Jeppe
Votes for this answer: 0
 
Emil Højbjerg
Reply

Hi Emil

Yes, it's possible. You need to use the CustomField class in order to do it.

// Creates a new CustomField object.
// "systemname" is the SystemName of the field. This value must conform to the same rules as a column name in the database.
// "tablename" is the name of the table in which to create the CustomField. In this case it's "AccessUser".
// type is the type of the CustomField. This value is of type Dynamicweb.Modules.Common.CustomFields.CustomFieldType.Types.
var cf = new Dynamicweb.Modules.Common.CustomFields.CustomField("systemname", "tablename", type);
cf.Name = "Name of the field"; // This is used as the label in the UserManagement module
cf.Database = "Access.mdb"; // Defines which system databse to use. This is only relevant for solutions using MS Access.
cf.Save();

If you create a field of type RadioButtonGroup or DropDown then you will also have to create some options. Use the property "Options" on the CustomField object.

Hope this helps :)

- Jeppe
Works like a charm :-)!

Thanks!

 

You must be logged in to post in the forum