Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@eirikb

eirikb/test.js Secret

Created February 10, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eirikb/1b1186ab2c7dd0370864 to your computer and use it in GitHub Desktop.
Save eirikb/1b1186ab2c7dd0370864 to your computer and use it in GitHub Desktop.
function checkIfFieldExists(ctx, list, fieldName, cb) {
ctx.load(list.get_fields().getByInternalNameOrTitle(fieldName), 'Id');
ctx.executeQueryAsync(function() {
cb(true);
}, function() {
cb(false);
});
}
var c = SP.ClientContext.get_current();
var l = c.get_web().get_lists().getByTitle('Test');
checkIfFieldExists(c, l, 'FailField', function(exists) {
console.log('Field exists:', exists);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment