When uploading a document to a document library, if you drag and drop it doesn't ask for any meta data and gets checked out to the logged in user. Any suggestion to make users enter metadata through drag and drop?
Asked
Active
Viewed 290 times
1 Answers
3
Apply metadata to documents when drag and drop a file. There is a bit of hardcoding, but here is what I did and it seems to be working. I am still testing this. If you have a way to get the current listname at runtime that would be brilliant! I have this in a CEWP on the library allitems.aspx page itself. I will move this to masterpage after more testing. You can also change the caml to get the list items.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script><script unselectable="on">
window.onload = function(){
setTimeout( function(){
if(typeof UploadProgressFunc != "undefined"){
$.getScript("path_to_my_custom_js_file/DragDrop.Extended.js");
}
}, 4000);
};
function MyNewFunction() {
var caml = "<View><Query><Where>"
+ "<Eq><FieldRef Name='FSObjType' /><Value Type='int'>0</Value></Eq>"
+ "</Where>"
+ "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>"
+ "</Query>"
+ "<ViewFields><FieldRef Name='ID' /></ViewFields>"
+ "<RowLimit>1</RowLimit>"
+ "</View>";
var ctx = SP.ClientContext.get_current()
var web = ctx.get_web();
var list = web.get_lists().getByTitle("test1")
var query = new SP.CamlQuery();
query.set_viewXml(caml);
var items = list.getItems(query);
ctx.load(items)
ctx.executeQueryAsync(function() {
var enumerator = items.getEnumerator();
enumerator.moveNext();
var item = enumerator.get_current();
var id = item.get_id();
//alert(id);
_MyGotoEditForm(id)
}, function() {
//failure handling comes here
alert("failed");
});
}
function _MyGotoEditForm(id) {
var options = SP.UI.$create_DialogOptions();
options.title = "Add File Metadata";
options.url = "http://**SITENAME**/**LIBRARYNAME**/Forms/EditForm.aspx?ID="+id;
options.autoSize = true; SP.UI.ModalDialog.showModalDialog(options); }
File Drag and Drop Prompt Metadata Properties Dialog
Also check this one: http://bhanuprakashbysani.blogspot.com/2014/12/enforce-drag-and-drop-documents-to.html
Waqas Sarwar MVP
- 57,008
- 17
- 43
- 79