Created
July 25, 2015 13:59
-
-
Save vman/6753ef89e26697906d0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| createcontenttype: function () { | |
| var dfd = $.Deferred(); | |
| var ctx = getContext(); | |
| var appctx = getAppContextSite(ctx); | |
| var targetWeb = appctx.get_site().get_rootWeb(); | |
| var fields = targetWeb.get_fields() | |
| var field = fields.getByInternalNameOrTitle(sitecolumnname); | |
| ctx.load(fields); | |
| ctx.load(field); | |
| var ctci = constructContentTypeCreationInformation(contenttypeid, contenttypename) | |
| var newType = targetWeb.get_contentTypes().add(ctci); | |
| ctx.load(newType); | |
| ctx.executeQueryAsync(succeed, fail); | |
| function succeed(sender, args) { | |
| var fieldRefs = newType.get_fieldLinks(); | |
| ctx.load(fieldRefs); | |
| ctx.executeQueryAsync( | |
| function () { | |
| var flci = constructFLCI(field); | |
| newType.get_fieldLinks().add(flci); | |
| newType.update(); | |
| ctx.executeQueryAsync(function () { dfd.resolve(); }, | |
| function (sender, args) { | |
| console.log("Content type creation failure: " + args.get_message()); | |
| dfd.reject(); | |
| }); | |
| }, | |
| function (sender, args) { | |
| console.log("Content type creation failure: " + args.get_message()); | |
| dfd.reject(); | |
| }); | |
| } | |
| function fail(sender, args) { | |
| console.log("Content type creation failure: " + args.get_message()); | |
| dfd.reject(); | |
| } | |
| return dfd.promise(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment