IntroductionIn this article you will see how to create custom content type in SharePoint 2010 using ECMAScript(Navigate to the site, click on Site Actions. Click on Site Settings. In the Galleries section, click on Site Content Types).Steps Involved
var contentTypeCollection;
function createContentType() { var clientContext = new SP.ClientContext.get_current(); if (clientContext != undefined && clientContext != null) { var web = clientContext.get_web(); this.contentTypeCollection = web.get_contentTypes(); var newContentType = new SP.ContentTypeCreationInformation(); newContentType.set_name('Custom Content Type'); newContentType.set_description('My custom content type'); this.contentTypeCollection.add(newContentType); clientContext.load(this.contentTypeCollection); clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); } }
function onQuerySucceeded() { alert("Content Type created successfully") }
function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }</script> <input id="btnCreateContentType" onclick="createContentType()" type="button" value="Create Content Type" />
ReferenceSP.ContentType.name Property - http://msdn.microsoft.com/en-us/library/ee549502.aspx SummaryThus in this article you have seen how to create a custom content type in SharePoint 2010 using ECMAScript.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: