Create a ContentType with an ID

Sep 29, 2011 at 6:26 PM

I have successfully created a ContentType using SPServices and 99% of it works flawlessly! The other 1% could be me, but I need to validate some info.

I am using the contentTypeProperties option to send in some properties like the Group and ID. The Group option works and the ContentType is found in that

group when I look for it. The ID property I thought was supposed to create the ContentTypeId with the ID that I passed in. However, it doesn't do this.

This is not really an issue if the following is true: A list template that uses the ContentType can be loaded on a different farm where the same ContentType is created.

Basically I am writing code to make it easier to create a ContentType with fields that I can load on different farms. I will then have a list template that uses the ContentType.

If the ID has to match as I think it does, this might not work. So does the CreateContentType always ignore a passed ID or am I missing an attribute somewhere.


Sep 30, 2011 at 5:42 AM


Since you are creating the Content Type in different Farms, then the GUID will be different. I don't think you get to choose it; it's assigned at creation time. Once you've created the Content Type, you should be able to determine it's GUID and go from there. Assuming I understand the question correctly!


Sep 30, 2011 at 10:38 AM

I believe that it what it is doing, but according to the documentation, you are able to supply a ContentTypeProperties argument and the example XML supplied has an ID. It is possible that this ID is not the same as a ContentTypeId, but it appears to be in the docs! If I were able to use VisualStudio to create a full feature I would be able to set the ContentTypeId easily and it would be the same no matter where it is installed. I just think either the docs are wrong, or I missed something. I will test the results of creating a list template and see if it will work. If not, it will be a much longer process. But I won't personally blame you for that though I might call you a few unclean names! Just kidding of course! This library has helped me in so many ways!

Sep 30, 2011 at 12:56 PM

Well, so I won't have to call anyone names! :) It seems that the name is more important than the ID. I was able to create a list template on a dev site that used the content type. I added the content type to the production site with the same code and then created a list with the template and it worked! This will be a major time saver for us. I might even see if I can create the list from the content type using SPServices and then that would be even better, but already this is huge!