So I'm trying to create a list then add a few fields to it. I've nabbed some code but it's not seeming to work. At the moment the list is created but the new column aint added despite it saying it is. Any thunks?
function createlist() {
alert('wotcha');
alert(filename);
//Create list
$().SPServices({
operation: "AddList",
listName: filename,
description: "List created for quiz: "+filename,
templateID: 100
});
//Add field: Score
var nfields = "";
nfields += "<Fields><Method ID='1'><Field Type='Text' DisplayName='DayCount' ResultType='Text'></Field></Method></Fields>";
$().SPServices({
operation: 'UpdateList',
listName: filename,
newFields: nfields,
completefunc: function(xData, Status) {
tp1 = xData.responseText;
alert(tp1);
tp4 = tp1.indexOf("errorstring");
if (tp4 < 0) {
alert("Fields created!");
}
else {
// Error creating fields!
alert("Error creating fields!");
}
}
});
alert('should be doned');
}