Hello,
I have perused the site for some tips on creating a custom field programmatically. Failing to find a solution, it was time for a new topic.
During the initial startup of a server side app, I'd like to check for the existence of a text custom field, and if it doesn't exist, create it.
I'm not so concerned about checking the existence, we do that all the time, creating it, I've little clue. How is something like that accomplished?
Thanks!
Programmatically creating Custom Fields
Moderator: Phil Barton
Programmatically creating Custom Fields
I blog at http://DanVanFleet.com on SoftPro and other things
-
- Posts: 1382
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: Programmatically creating Custom Fields
Try this...
Other attributes are available by looking up ICustomFieldDefinition in the SDK Help file.
Code: Select all
public CreateCustomField(SelectServer ss)
{
ICustomFieldsManager cfMgr = ss.GetService<ICustomFieldsManager>();
// Create get a new custom field object and set its attributes.
ICustomFieldDefinition cf = cfMgr.NewCustomFieldDefinition();
cf.Context = cfMgr.AvailableContexts.Where(t => t.Name == "Order").First();
cf.Name = "SpecialDate#";
cf.Label = "The special date";
cf.DataType = CustomFieldDataType.Date;
// Save it to Select.
cfMgr.ApplyChanges(cf);
}
Bob Richards, Senior Software Developer, SoftPro
Re: Programmatically creating Custom Fields
Ahh, you make it look so easy, and fast! Thanks a ton.
I blog at http://DanVanFleet.com on SoftPro and other things