Iam getting this error "Request failed. Value does not fall within the expected range" when i create list with choice Field/column and Taxonomy Field.
Here is my code for creating the List, and then in my second function i create all the Fields:
var clientContext = new SP.ClientContext(_spHostUrl);
var oWebsite = clientContext.get_web();
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title('GNTiles_');
listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
this.oList = oWebsite.get_lists().add(listCreationInfo);
clientContext.load(oList);
clientContext.executeQueryAsync(function () {
addGNTilesFieldsToList(gnPagesId, termStoreId, termSetIdProcess);
console.log('List GNTiles created..');
}, function (sender, args) {
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
});
Creating all Fields:
var addGNTilesFieldsToList = function (gnPagesId, termStoreId, termSetIdProcess) {
var clientContext = new SP.ClientContext(_spHostUrl);
var oList = clientContext.get_web().get_lists().getByTitle('GNTiles_');
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'Text\' Type=\'Note\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'Class\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'TextClass\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'ClickAction\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'TextAnchor\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'ElementType\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'TextRotate\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'sPropJSON\' Type=\'Note\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'GoToPage\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName=\'Corner\' Type=\'Text\' />', true, SP.AddFieldOptions.defaultValue);
this.oField = oList.get_fields().addFieldAsXml('<Field DisplayName="GNPage" Type="Lookup" List="' + gnPagesId + '" ShowField="GNPage" RelationshipDeleteBehavior="None" />', true, SP.AddFieldOptions.defaultValue);
var choiceDropDownField = clientContext.castTo(
this.oField = oList.get_fields().addFieldAsXml('<Field Type="Choice" DisplayName="svgShape" Name="svgShape" Format="Dropdown" />', true, SP.AddFieldOptions.addToDefaultContentType), SP.FieldChoice);
var availableDropChoices = Array("circle", "ellipsis", "rect", "path", "polygon", "polyline");
choiceDropDownField.set_choices(availableDropChoices);
choiceDropDownField.update();
var taxFieldProcess =
'<Field Type="TaxonomyFieldType" DisplayName="Process" ShowField="Term1033" Required="FALSE" EnforceUniqueValues="FALSE" StaticName="Process" Name="Process" > \
<Default /> \
<Customization> \
<ArrayOfProperty> \
<Property>\
<Name>SspId</Name>\
<Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">' + termStoreId + '</Value>\
</Property> \
<Property>\
<Name>TermSetId</Name>\
<Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">' + termSetIdProcess + '</Value>\
</Property> \
<Property>\
<Name>TextField</Name>\
<Value xmlns:q2="http://www.w3.org/2001/XMLSchema" p4:type="q2:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance"></Value>\
</Property> \
</ArrayOfProperty> \
</Customization> \
</Field>';
this.oField = oList.get_fields().addFieldAsXml(taxFieldProcess.toString(), true, SP.AddFieldOptions.defaultValue);
var fieldNumber = clientContext.castTo(oField, SP.FieldNumber);
fieldNumber.update();
clientContext.load(oField);
clientContext.executeQueryAsync(function () {
console.log('Fields created..');
}, function (sender, args) {
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
});
}
I get this error first time i try to create the List and Fields, List always get created, but NOT the Fields. So each time i have to delte the List, and re-create it, then i dont get this error message. By googling a litle i found that it maybe can be List View Treshold value issue, and i did change the Treshold value without any luck....
How can i fix this?
reg gonadn