How to Add New Collum in Content Center Itens by Code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I have a question about the possibility of programmatically adding new columns to existing items within the Content Center. I need to add these 2 new columns to all items, and I would like to do it via an API, is that possible?
I am trying with the code below, but when executing cf.TableColumns.Add it returns an unhandled error. Please, is the code correct, or is there another way to do this? Thank you in advance!
[TestMethod]
public void AddCollums()
{
string id = "Inventor User Defined Properties";
// Content center itens
ContentTreeViewNode treeViewTopNode = InvApp.App.ContentCenter.TreeViewTopNode;
var fm = treeViewTopNode.ChildNodes["Recursos"].ChildNodes["Bicos pulverizadores"];
foreach (ContentFamily cf in fm.Families)
{
Console.WriteLine("\t" + cf.DisplayName);
cf.TableColumns.Add("ModelCode", "", ValueTypeEnum.kStringType,false,false, id, "ModelCode");
cf.TableColumns.Add("ModelName", "Nome", ValueTypeEnum.kStringType,false, "{PARTNUMBER}", id, "ModelName");
cf.Save();
}
}