If you drag and drop ONE file (NO FOLDERS) you are not presented with the edit properties screen. My users are not going to go back and apply metadata - its TOO many clicks.

Now I've found this code on several sites but nobody has bothered to provide instructions beyond add it to a script editor web part.

(function (_window) {
var maxTimeForReplaceUploadProgressFunc = 10000;
function replaceUploadProgressFunc() {
    if (typeof _window.UploadProgressFunc != 'undefined') {
        _window.Base_UploadProgressFunc = _window.UploadProgressFunc;
        _window.UploadProgressFunc = Custom_UploadProgressFunc;
        console.log('replaced dialog');
    } else if (maxTimeForReplaceUploadProgressFunc > 0) {
        maxTimeForReplaceUploadProgressFunc -= 100;
        setTimeout(replaceUploadProgressFunc, 100);
setTimeout(replaceUploadProgressFunc, 100);

function Custom_UploadProgressFunc(percentDone, timeElapsed, state) {
    _window.Base_UploadProgressFunc(percentDone, timeElapsed, state);
    var messageType = ProgressMessage.EMPTY;
    switch (state.status) {
        case 1:
            messageType = ProgressMessage.VALIDATION;
        case 3:
            messageType = ProgressMessage.UPLOADING;
        case 4:
            messageType = ProgressMessage.UPLOADED;
        case 5:
            messageType = ProgressMessage.CANCELLED;

    function OpenEditFormForLastItem(state) {
        var caml = '';
        caml += "<View>";
        caml += "<Query>";
        caml += "<Where>";

        if (state.files.length > 1) {
            caml += "<In>";
            caml += "<FieldRef Name='FileLeafRef'/>";
            caml += "<Values>";
        } else {
            caml += "<Eq>";
            caml += "<FieldRef Name='FileLeafRef'/>";

        state.files.forEach(function (file) {
            //only succesfull uploaded files that arent overwrites
            if (file.status === 5 /*&& !file.overwrite*/) {
                caml += "<Value Type='File'>" + file.fileName + "</Value>";
        }, this);

        if (state.files.length > 1) {
            caml += "</Values>";
            caml += "</In>";
        } else {
            caml += "</Eq>";

        caml += "</Where>";
        caml += "<OrderBy><FieldRef Name='ID' Ascending='True' /></OrderBy>";
        caml += "</Query>";
        caml += "<ViewFields><FieldRef Name='ID' /></ViewFields>";
        caml += "<RowLimit>500</RowLimit>";
        caml += "</View>";

        var cntxt = SP.ClientContext.get_current();
        var web = cntxt.get_web();
        var list = web.get_lists().getByTitle(window.ctx.ListTitle);
        var query = new SP.CamlQuery();
        var items = list.getItems(query);
        cntxt.load(list, 'DefaultEditFormUrl');
        cntxt.executeQueryAsync(function () {
            var listEnumerator = items.getEnumerator();
            function openEditForItem() {
                if (listEnumerator.moveNext()) {
                    var item = listEnumerator.get_current();
                    var id = item.get_id();

                    var options = SP.UI.$create_DialogOptions();
                    options.title = "Add File Metadata";
                    **options.url = list.get_defaultEditFormUrl() + '?ID=' + id;**
                    options.autoSize = true;
                    options.dialogReturnValueCallback = openEditForItem;
                } else {
        }, function (error, args) {
                console.log("failed to get new uploaded items");

I realize that there is a place in input the URL of the list and the list id, but what else has to be altered in this code. I'm schooled in HTML and other languages but I'm not that great with Javascript and I've been struggling with this for 3 days now. Any and all help would be greatly appreciated. I've already moved 100s of docs into the new structure and I may have to just leave their folders intact....


You could use this trick to apply metadata, without multiple clicks.

Depending on how your documents are structured (are there multiple document libraries, so that a file plan of sorts is being followed?), this could be an option for you to use.

I imagine you will be migrating files one department at a time. In that case, you would need to define the metadata for that department / document library. Then uploading and applying the metadata to each document should be more managable. Some collaboration with the department would be helpful to create useful metadata as well as to organise their documents in to document libraries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.