4

I would like to set all document properties programmatically inside the event handler. I do not manage to skip an edit form after the document is uploaded. Any help is welcome.

3 Answers3

1

JavaScript solution for SharePoint 2013

In SP.UI.Dialog, there is a function to close a dialog : commonModalDialogClose

Takes two parameters, commonModalDialogClose(dialogResult, returnValue)

dialogResult is an enum (here is an extract from SP.UI.Dialog.js :

SP.UI.DialogResult.prototype = {
    invalid: -1,
    cancel: 0,
    OK: 1
};

Solution : When using the upload.aspx page, you will be redirected to the EditForm.aspx including a QueryString parameter, Mode, that will be tagged as Upload. Using that information, the dialog can be closed. The QueryString parameter is retrieved using the GetUrlKeyValue SharePoint native function.

GetUrlKeyValue(keyName, bNoDecode, url, bCaseInsensitive)

add the following into the library EditForm.aspx using JSLink

(function (){
    var mode = GetUrlKeyValue("Mode", false, window.location.href, true);

    if (mode == "Upload")
    {
        //commonModalDialogClose(dialogresult, resultValue)
        //dialog result : -1 = invalid; 0 = cancel; 1 = ok
        //resultValue : text
        commonModalDialogClose(0, null);
    }
})();
JayHell
  • 1,478
  • 9
  • 19
  • Hi @JayHell, I'm new in Sharepoint, and i find your solution te be a good one, however i don't know where and how to add this Javascript code, and what is JSLink ?.

    I have a Custom Edit form which include some new columns i created. and i want to know how to apply this solution.

    – ihssan Jun 28 '17 at 08:20
1

Take a look at this article http://hristopavlov.wordpress.com/2008/04/30/editformaspx-not-shown-when-uploading-a-document/

Mary Rivers
  • 798
  • 2
  • 9
  • 16
0

There is a matter of at which point in the event handling the document properties should or can be updated. This post explains the various Events and their variations ('-ing', '-ed', etc) - not all properties are available during the synch/asynch event handling - Managing ItemUpdating and ItemUpdated Events..

An alternative, is to use PowerShell for document upload. Paul Childs has a PowerShell example that can provide a solution - Bulk upload files with metadata into SharePoint using PowerShell: UPDATE

Supriyo SB Chatterjee
  • 2,911
  • 14
  • 22