cancel
Showing results for 
Search instead for 
Did you mean: 

Edit Metadata upon upload

yuhuayang
Champ in-the-making
Champ in-the-making
Hi All

I am looking for any tutorial or any guide to implement a simple feature:

when a user uploads a document, he is prompted to enter the custom metadata associated with the document type

It is best illustrated by this add-on built commercially: http://alfresco.fme.de/extension-gallery/overview/edit-meta-data-during-upload/

In lieu of a fancy pop-up, I am willing to settle for redirecting the user upon upload to the Edit Properties page and edit the metadata from there, I thought that I could simply add a custom rule which upon meeting conditions it executes a javascript, uploaded to Repository->DataDictionary->Scripts. However it seems that the javascripts uploaded into here are server side and so does nothing in terms of redirection.

How can I solve this problem? I found a few threads on here and stackoverflow of people trying to implement this, but nobody has yet posted a solution, did they all just give up or did fme.de remove all those posts since if there was a posted solution, nobody would buy their addon?

Thanks for your help
17 REPLIES 17

rjohnson
Star Contributor
Star Contributor
I cannot offer a tutorial or a detailed guide, but you will need to modify the upload action scripts and get the to do 2 things:-

Only allow the upload of one document at a time
Throw the user to the Edit Properties screen when the upload is complete.

Now, there is a tutorial about amending the upload scripts at

http://www.ixxus.com/blog/2011/09/customising-upload-files-dialog-alfresco-share


but this is about adding metadata before upload (which may suit you). However it will tell you where the respective files you need to change are and rather than the hos of changes you would need to make to add metatdata before upload then you just need to get the nodeRef of the uploaded document returned and redirect the browser to the edit properties URL. To throw a user to an edit properteis form is a simple redirect to a URL. You can work this URL out by showing ant document in Document Details and hovering over the "Edit Properties" option. Basically, its a static URL with a nodeRef as a parameter.

Good luck

Bob Johnson

yuhuayang
Champ in-the-making
Champ in-the-making
Hi Bob

Thanks for your response. I took a look and it looks like I need to modify the dnd-upload.js/flash-upload.js/html-upload.js in tomcat/webapps/share/components/upload

Thanks

yuhuayang
Champ in-the-making
Champ in-the-making
I have done it after days of researching. I am posting my solution so that others who need to do this will be able to.

My solution does the following: when a user invokes the drag-n-drop function to add a file, after upload is complete and the user clicks on the OK button in the upload dialog, he will be redirected to the Edit Properties page to input metadata. If multiple files are dragged in, only the first file's Edit Properties window will be shown.

Steps:
1. find the dnd-upload.js file in tomcat/webapps/share/components/upload
2. open the file and find the function onCancelOkButtonClick
3. at the end of the function, put this code in:

//code to redirect user to edit metadata after upload
         if(this.state === this.STATE_FINISHED)
         {
             
             // update noderef from response
             var nodeRefURL = "edit-metadata?nodeRef=" + f.nodeRef;
             
             //redirect
              Alfresco.util.navigateTo(nodeRefURL);
         }

4. copy the code and convert it to the minified version and name it dnd-upload-min.js (use something like http://jscompress.com/)
5. go back into tomcat/webapps/share/components/upload, rename the existing dnd-upload-min.js for backup, then put the one you just modified into this folder
4. refresh your page multiple times (due to caching)
5. Try a drag-n-drop, you should be redirected to the Edit Properties page after you hit OK on the upload dialog.

Hope this helps someone in the future, now there is no need to pay for an expensive add-on!

gsdenys
Champ in-the-making
Champ in-the-making
I think this functionality is the most asked by Alfresco Share users. I have made plans to create this functionality but unfortunatly it is in my TODO List yet. So, I think it is not so dificult. If you're thinking in create this project as GPL or other licenses like it, I can help you in the project.

to do this project I think that you can follow this steps:

1) Enable functionality to get the list of document types dinamically. This can use a modification from this script to list just relevant document types.


var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var model = Packages.org.alfresco.model.ContentModel;
var dictionaryService = ctx.getBean("DictionaryService");
types = dictionaryService.getSubTypes(model.TYPE_CONTENT, true).toArray();
for each(var type in types){
  print(type);
}


2) Modify the updload module to create a list of uploaded nodes NodeRef.

3) after upload call sequencially the module edit-metadata.

I hope can help you in your project, and if possible publish it to alfresco addons.

Good Luck

framt
Champ in-the-making
Champ in-the-making
Thank you,

I think 2 solutions are definitely better than 1.

I am going to try both methods and let you know how it works out.

-Framt

framt
Champ in-the-making
Champ in-the-making
Yuhuayang's method has been successful for me. Very easy to custom tailor as well.

gsdenys
Champ in-the-making
Champ in-the-making
The yuhuayang solution also has been done for me when i updoad a single document. Form multiple document, the edid metadata just called for the first document.

So, I think it is a easy and so good solution. I will go try to customize this solutions for try sequentially for all documents.

Guys, Are you already have any solution for this point?


gsdenys
Champ in-the-making
Champ in-the-making
For this solution works with flash upload do the same to flash-upload.js

copeland
Champ in-the-making
Champ in-the-making
Hi! I 've been testing your solution and it works Ok with dnd-upload and flash-upload but I've a got problem with html-upload. After of loading the edit-medata page I get an error if click on "Ok" or "Cancel" buttons because of it uses a wrong target URL. Anyone had the same problem?

Alfresco Share shows this error after clicking


The Web Script /alfresco/s/api/upload.html has responded with a status of 405 - Method Not Allowed.
405 Description:   The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.

Message:    09150870 Script url /api/upload.html does not support the method GET
   
Exception:   
org.springframework.extensions.webscripts.WebScriptException - 09150870 Script url /api/upload.html does not support the method GET
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.