So I’ve been having issues with a module I built to create content types. It goes by steps like this: 1 – I create an empty content type (it may or may not inherit from another content type -which exists on the site-) 2 – The I add fields (again, they do exist on the site) to the content type as field links 3 – I update the content type indicating that the childs should be updated to.
In code is something like:
Firts step:
SPContentTypeId spParentContentTypeID = new SPContentTypeId(_ParentContentyTypeID);
SPContentTypeCollection hubContentTypeCollection = _SPWeb.ContentTypes;
SPContentType spParentContentType = hubContentTypeCollection[spParentContentTypeID];
_SPContentType = new SPContentType(spParentContentType, hubContentTypeCollection, _ContentyTypeName);
_SPContentType.Group = _ContentTypeGroup;
_SPContentType.Hidden = false;
hubContentTypeCollection.Add(_SPContentType);
Second step (this goes inside a for which iterates through a string collection with the field internal names)
_SPField = _SPWeb.Fields.GetField(_DocumentTypeField.Field.Name);
if (!_SPContentType.Fields.Contains(_SPField.Id)){
_SPContentType.FieldLinks.Add(new SPFieldLink(_SPField));
_SPContentType.Update(true);
}
The thing is if I create a different content type with the same fields specified on an existing content type the content type is created but the fields do not appear on the native SharePoint content type management module, but If I query the content type using powershell, the fields are there.
Now the content types are being created on a content type hub, which leads me to my second issue.
If I edit a previously existing content type (using my module, off course) and I mark it as republish it does not deploy the changes to the subscribers. The content type remains as it was created.
Any Ideas?