cancel
Showing results for 
Search instead for 
Did you mean: 

Force user to edit metadata on upload

sharifu
Confirmed Champ
Confirmed Champ
I would like to force users to enter metadata once they upload their doc on the share.

how would I achieve the metadata to open automatically for users who use the browser and upload a file manually?
12 REPLIES 12

chrisliv
Champ in-the-making
Champ in-the-making
I won't be much help on this, I gave up on the same issue a while ago. Here are my last links for this issue;

See the 'edit metadata during upload' addon (I can't recall why but I couldn't use it in my setup)
http://alfresco.fme.de/extension-gallery.909.0.html

I guess a webscript is the go
https://forums.alfresco.com/en/viewtopic.php?f=4&t=24433

good luck

sharifu
Confirmed Champ
Confirmed Champ
The first link is not open source, your second link does not give an example of how to do it, just shows sample scripts of upload.

I assume  I have to edit the sample script and add something on upload success to open the metadata?

Does anyone know what it is i need to call?

sharifu
Confirmed Champ
Confirmed Champ
Has anyone done this or can give detail instructions on how to do this. open the metadata for edit once a file is uploaded.

guilherme_souza
Champ in-the-making
Champ in-the-making
Hello,

in my Alfresco server, I've personalized the update form, but i've disabled the flash player and i've lost the Drag and Drop function.

First, in the file share-documentlibrary-config.xml, search for the adobe flash option and set to false, if you don't find you can add it.

<config evaluator="string-compare" condition="DocumentLibrary">
    <file-upload>
         <adobe-flash-enabled>true</adobe-flash-enabled>
         <in-memory-limit>262144000</in-memory-limit>
    </file-upload>
</config>
File Path: C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\share-documentlibrary-config.xml

After this, in the file html-upload.get.html.ftl, in the 'htmlupload-form', we have to edit the new labels, text boxes, etc. I suggest you create a new div with the new itens. Example:

<form id="${el}-htmlupload-form"
            method="post" enctype="multipart/form-data" accept-charset="utf-8"
            action="${url.context}/proxy/alfresco/api/upload.html" name="form1">
       <div id="${el}-metadataSection-div">
      <div class="yui-gd">
          <div class="yui-u first">
                          <label for="${el}-desc">Description</label>
                    </div>
               <div class="yui-u">
                          <input type="text" id="${el}-desc" name="desc" tabindex="1" />
                    </div>
                </div>
       </div>
</form>
File Path: C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\upload\html-upload.get.html.ftl

So, now we have to edit the upload javascript in the file upload.post.js. Search for the function 'main()' that is where we have to put the code.

     var  description = "";
     var desc = args.desc;

        /**
          * Create a new file.
          */
         var newFile = destNode.createFile(filename);
        
         newFile.properties.description = descricao;
        
         if (contentType !== null)
         {
            newFile.specializeType(contentType);
         }

         newFile.properties.content.write(content, false, true);
         newFile.save();
File Path: C:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\repository\upload\upload.post.js

To force the user to fill the fields created, you have to edit the file C:\Alfresco\tomcat\webapps\share\components\upload\html-upload-min.js.

sharifu
Confirmed Champ
Confirmed Champ
I have tried this but its not working for me. when i upload i see the description field but after i click save and go to the properties of the file. The description field is blank

sharifu
Confirmed Champ
Confirmed Champ
I managed to figure it out but it only works for title and description so far.

What if i have my own aspect with properties that i want to fill up with. is this how i do it?

html-upload.get.html.ftl

<div class="yui-gd">
               <div class="yui-u first">
                  <label for="${el}-tparty">Third parties</label>
               </div>
               <div class="yui-u">
                  <input type="text" id="${el}-tparty" name="tparty" tabindex="0" />
               </div>
            </div>

upload.post.js


var tparty = args["tparty"]; //line 50 approx



case "tparty":           // line 124
                tparty = field.value;
                break;




//after aspect check line 380 approx

newFile.properties.thirdParties = tparty;
         newFile.properties.content.write(content, false, true);
         newFile.save();

In my custom model my property is called sp:thirdParties

guilherme_souza
Champ in-the-making
Champ in-the-making
What's the name of the property that you're trying add to the file ?

sharifu
Confirmed Champ
Confirmed Champ
third Parties

guilherme_souza
Champ in-the-making
Champ in-the-making
Please, past the code of the aspect that is in the contentModel.xml