I want to retrieve file Url in all of that folder. I use javascript. Problem is it console the last item. I do not know why. Please help. Thanks
function checkAttachment(AttachID,getAttachmentStatus){
var itemId = AttachID;
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
for(var i = 0; i<itemId.length; i++){
if(getAttachmentStatus[i] == true){
var attachmentFolder=web.getFolderByServerRelativeUrl('Lists/Purchase2/Attachments/'+itemId[i]);
//console.log(attachmentFolder);
attachmentFiles = attachmentFolder.get_files();
console.log(attachmentFiles);
ctx.load(attachmentFiles);
ctx.executeQueryAsync(Function.createDelegate(this,this.onGetAttachmentSucc),Function.createDelegate(this,this.onGetAttachmentFail));
}
}
}
function onGetAttachmentSucc(sender, args) {
console.log(attachmentFiles);
var i=0;
for(var file in attachmentFiles)
{
if(attachmentFiles.itemAt(i) != undefined){
console.log(attachmentFiles.itemAt(i).get_serverRelativeUrl());
i++;
}
}
}
function onGetAttachmentFail(sender, args) {
alert("sorry!");}
sorry for my dirty code T_T