When using JSOM to add a new site column to a 2013 SharePoint web, I get the following error
Column 'ProgramName' does not exist. It may have been deleted by another user. https://server.org/it-test/jpaugh/awesomeSite
I'm using the following code. Am I doing this correctly?
var context = SP.ClientContext.get_current()
var fields = context.get_web().get_fields();
var formatted = "<field Name='ProgramName' DisplayName='Program Name' Required='true'"
+ " Group='Awesome' Type='Text' MaxLength='100'></field>";
fields.addFieldAsXml(formatted, false, SP.AddFieldOptions.addFieldCheckDisplayName);
context.executeQueryAsync(success, failure);
function success() {
console.log("Request success");
}
function failure(sender, args) {
console.error("Request failed: " + args.get_message());
}