If you change a column name or a list name after its been saved on SharePoint, javascript can no longer access it. By creating the list first in an excel sheet and uploading it to the site I was able to prevent renaming of column names in the designer.
sharepoint list not able to be written to using javascript
-
05-07-2023 - |
Question
I've made a testing application in SharePoint that will display a test, grade it and then save the test score back to SharePoint. My boss decided it would be nice if we could review the questions and answers that were entered. I created a new list with 156 rows, 78 multi-line rows for the questions and 78 yes/no for correct or not. On the delegate function I get an error,
"The column "q1" does not exist. It may have been deleted by another user......".
I can assure you that column q1 does exist. Any ideas on the issue here?
function updatedRecordedResults(graded) {
graded = ingraded;
var currentContext = new getContext(); //gets current context of SP site
var oList = currentContext.web.get_lists().getByTitle(window.recordedResults); //gets the list by name
var itemCreateInfo = new SP.ListItemCreationInformation();
this.oListItem = oList.addItem(itemCreateInfo);
this.oListItem.set_item("Title", window.user);
for (var i = 0; i < graded.length; i++) {
oListItem.set_item("q" + (i + 1), window.globalTest[i].question);
oListItem.set_item((i + 1) + "a", graded[i]);
}
oListItem.update();
currentContext.context.load(oListItem);
currentContext.context.executeQueryAsync(Function.createDelegate(this, this.updateRecordedResults), Function.createDelegate(this, this.failedupdateRecordedResults));
}
function updateRecordedResults() {
alert("succeeded");
}
function failedupdateRecordedResults(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow