I'm using SharePoint 2013 online and trying to save a item to a folder content type in a document libary I think the code is nearly rigth but i am getting this error when i hit save button have anyone else had this problem?
Failed Error:Input string was not in a correct format.
Error on this line.
appContext.executeQueryAsync(function () {
This is my function ctName is global.
ctName = 'IFUSimon';
function createListItem() {
console.log("1");
if (itemId == 'null') {
var listCreationInformation = new SP.ListItemCreationInformation();
listCreationInformation.set_underlyingObjectType(SP.FileSystemObjectType.folder);
var folderName = $('#Title').val();
if (folderName != "") {
listCreationInformation.set_leafName(folderName);
} else {
alert('No title');
return false;
}
listItem = list.addItem(listCreationInformation);
console.log("3");
var listContentTypes = list.get_contentTypes();
console.log("4");
appContext.load(listContentTypes);
console.log("5");
appContext.executeQueryAsync(function () {
console.log("6");
var ct;
console.log("7");
var ct_enumerator = listContentTypes.getEnumerator();
console.log("8");
while (ct_enumerator.moveNext()) {
ct = ct_enumerator.get_current();
if (ct.get_name() == ctName) {
CTID = ct.get_id();
}
}
listItem.set_item('ContentTypeId', CTID);
console.log("kmr du hitsnart");
setItems();
console.log("kmr du hitsnartklarrrr");
}, fail);
}
else {
listItem = item;
console.log("2");
setItems();
}
}
Log from chrome console
1
3
4
5
Failed Error:Input string was not in a correct format.
0 commentaires:
Enregistrer un commentaire