I'm following this example on how to get the links to list attachments. My console logs 'ReferenceError: id is not defined'. If I, however, hard code an arbitrary listitemid (i.e. 1), the code works fine. My code is as follows:
$().SPServices({
operation: "GetAttachmentCollection",
listName: "mylist", //my list name
ID: id,
completefunc: function(xData, Status) {
//console.log( Status );
//console.log( xData.responseText );
var output = "";
//debugger;
$(xData.responseXML).find("Attachments > Attachment").each(function(i, el) {
var $node = $(this),
filePath = $node.text(),
arrString = filePath.split("/"),
fileName = arrString[arrString.length - 1];
output += "<a href='" + filePath + "' target='_blank'>" + fileName + "</a><br />";
});
$("#drop-zone").html(output);
}
});
ID seems to be set incorrectly (should refer to the listitemid). I have no idea on how to retrieve the correct id of a list. Can someone explain to me how I can obtain the listitemid of the item I'm currently creating? The code is added to the newifs.aspx of a certain list - if that matters - .