Hi,
Is adding customfields to users supported in the API - and if so, where?
Thanks :-)!
Developer forum
E-mail notifications
User custom fields
Emil Højbjerg
Posted on 23/05/2011 10:46:58
Replies
Jeppe Eriksson Agger
Posted on 23/05/2011 12:23:14
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
Posted on 23/05/2011 12:55:58
Works like a charm :-)!
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
Thanks!
You must be logged in to post in the forum