Update document properties when a new version is uploaded

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2014 07:58 AM
I would like to update document description only when user upload a new version of a document.
I don't know which file i have to modify, I suppose create-new-version.get.js but i'm not really sure.
Could you tell me whick file i have to update to do this ?
Thanks.
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2014 03:19 AM
You can check code from line num - 263.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2014 09:47 AM
I Tried update this file. I putted this line
updateNode.properties.description = "TEST";
and this one but still not working. Any ideas ?
existingFile.properties.description = "TEST";

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2014 12:50 AM
Working now ?
Can you please provide me the line number where you have made these changes?
You are uploading new version of any document from documentlibrary page/document details page.. right ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2014 05:15 AM

I tried this (begin in line 278) in upload.post.js
/** * Existing file handling. */ var existingFile = destNode.childByNamePath(filename); if (existingFile !== null) { // File already exists, decide what to do if (existingFile.hasAspect("cm:versionable") && overwrite) { existingFile.properties.description = "TEST"; //Added line !! // Upload component was configured to overwrite files if name clashes existingFile.properties.content.write(content); // Reapply mimetype as upload may have been via Flash - which always sends binary mimetype existingFile.properties.content.guessMimetype(filename); existingFile.properties.content.guessEncoding(); existingFile.save(); // Extract the metadata // (The overwrite policy controls which if any parts of // the document's properties are updated from this) extractMetadata(existingFile); // Record the file details ready for generating the response model.document = existingFile; // MNT-8745 fix: Do not clean formdata temp files to allow for retries. Temp files will be deleted later when GC call DiskFileItem#finalize() method or by temp file cleaner. return; }
And the second line here :
if (updateNodeRef !== null) { /** * Update existing file specified in updateNodeRef */ var updateNode = search.findNode(updateNodeRef); if (updateNode === null) { exitUpload(404, "Node specified by updateNodeRef (" + updateNodeRef + ") not found."); return; } if (updateNode.isLocked) { // We cannot update a locked document exitUpload(404, "Cannot update locked document '" + updateNodeRef + "', supply a reference to its working copy instead."); return; } if (!updateNode.hasAspect("cm:workingcopy")) { // Ensure the file is versionable (autoVersion = true, autoVersionProps = false) updateNode.ensureVersioningEnabled(true, false); // It's not a working copy, do a check out to get the actual working copy updateNode = updateNode.checkoutForUpload(); } // Update the working copy content updateNode.properties.description = "TEST"; //Line added !! updateNode.properties.content.write(content); // Reset working copy mimetype and encoding updateNode.properties.content.guessMimetype(filename); updateNode.properties.content.guessEncoding(); // check it in again, with supplied version history note updateNode = updateNode.checkin(description, majorVersion);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2014 02:25 AM
Please replace that line with,
existingFile.properties["cm:description"] = "TEST";
Hope this helps.!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2014 08:31 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2014 01:03 AM
Please do not change the javascript files directly and you'll have issues when you're upgrading alfresco version.
So, I would suggest try to use Alfreco folder rules to update the document description.
Please let me know, if you need example for this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 03:37 AM
Please, give me example.
