-1

I want to create a Structure Group in Tridion 2011 using core services Any idea?

Aquarius24
  • 1,806
  • 6
  • 33
  • 61

2 Answers2

8

This is the code:

var structureGroup = ClientAdmin.GetDefaultData(ItemType.StructureGroup, "tcm:0-2-1");
structureGroup.Title = "SG";
structureGroup.Directiry = structureGroup.Title.Replace(" ", ""),
structureGroup = (StructureGroupData) ClientAdmin.Create(structureGroup, new ReadOptions());

I don't think that any explanations are needed here, if you want to know more - check StructureGroupData class in CoreService API docs

Andrey Marchuk
  • 13,301
  • 2
  • 36
  • 52
2

The code above doesn't seem to be an standard Core Services API. Check this one.

CoreServiceClient channel = new CoreServiceClient("basicHttp_2011");
string organizationalItemId = "tcm:6-3-4";
StructureGroupData sg = new StructureGroupData();
sg.Id = "tcm:0-0-0";
sg.Title = "NewSG";
sg.LocationInfo = new LocationInfo() { OrganizationalItem = new LinkToOrganizationalItemData() { IdRef = organizationalItemId } };
sg.Directory = "NewSG";
sg = (StructureGroupData)channel.Save(sg, new ReadOptions());

You might note there that the Directory property cannot contain blank spaces. That is because it is validated by a regular expression. You can change it in the file cm_xml_usr.xsd located at [TRIDION_HOME]\bin.

Eric Huiza
  • 393
  • 1
  • 4