Last active
August 29, 2015 14:10
-
-
Save premchandpl/e3d9f0720590e7c7e428 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loopFileUpload(listName, id, listValues, fileCountCheck) { | |
var dfd = $.Deferred(); | |
uploadFile(listName, id, listValues[0].Files[fileCountCheck].Attachment).then( | |
function (data) { | |
var objcontext = new SP.ClientContext(); | |
var targetList = objcontext.get_web().get_lists().getByTitle(listName); | |
var listItem = targetList.getItemById(id); | |
objcontext.load(listItem); | |
objcontext.executeQueryAsync(function () { | |
console.log("Reload List Item- Success"); | |
fileCountCheck++; | |
if (fileCountCheck <= listValues[0].Files.length - 1) { | |
loopFileUpload(listName, id, listValues, fileCountCheck); | |
} else { | |
console.log(fileCountCheck + ": Files uploaded"); | |
alert('Item created with Multiple attachments'); | |
} | |
}, | |
function (sender, args) { | |
console.log("Reload List Item- Fail" + args.get_message()); | |
}); | |
}, | |
function (sender, args) { | |
console.log("Not uploaded"); | |
dfd.reject(sender, args); | |
} | |
); | |
return dfd.promise(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment