cancel
Showing results for 
Search instead for 
Did you mean: 

Custom metadata in document list

defty
Champ in-the-making
Champ in-the-making
I've made the necessary changes to get my custom metadata to display on the edit and document details screens, but I really need it to show in the document library/list view. I cant find any info on how to add it to here so could someone could point me in the right direction?


Thanks!
3 REPLIES 3

fiendius
Confirmed Champ
Confirmed Champ
Hallo,

I have the same problem and need a hint to the right way. Has anybody a idea to this problem?

Thank you!

woody
Champ in-the-making
Champ in-the-making
I'm trying to do that (still with not great success, cause I'm new to that) changing the file:

Slingshot/source/web/components/documentlibrary/documentlist.js

next to line 979 you can find this part of js code:

                  
if (record.custom && record.custom.isWorkingCopy)
                  {
                     /**
                      * Working Copy
                      */
                     desc += '<div class="detail">';
                     desc += '<span class="item"><em>' + scope.msg("details.editing-started.on") + '</em> ' + Alfresco.util.formatDate(record.modifiedOn) + '</span>';
                     desc += '<span class="item"><em>' + scope.msg("details.editing-started.by") + '</em> <a href="' + Alfresco.DocumentList.generateUserProfileUrl(record.modifiedByUser) + '">' + $html(record.modifiedBy) + '</a></span>';
                     desc += '<span class="item"><em>' + scope.msg("details.size") + '</em> ' + Alfresco.util.formatFileSize(record.size) + '</span>';
                     desc += '</div><div class="detail">';
                     desc += '<span class="item"><em>' + scope.msg("details.description") + '</em> ' + $links($html(description)) + '</span>';
                     desc += '</div>';
                  }
                  else
                  {
                     /**
                      * Non-Working Copy
                      */
                     desc += '<div class="detail">';
                     desc += '<span class="item"><em>' + scope.msg("details.modified.on") + '</em> ' + Alfresco.util.formatDate(record.modifiedOn) + '</span>';
                     desc += '<span class="item"><em>' + scope.msg("details.modified.by") + '</em> <a href="' + Alfresco.DocumentList.generateUserProfileUrl(record.modifiedByUser) + '">' + $html(record.modifiedBy) + '</a></span>';
                     desc += '<span class="item"><em>' + scope.msg("details.version") + '</em> ' + record.version + '</span>';
                     desc += '<span class="item"><em>' + scope.msg("details.size") + '</em> ' + Alfresco.util.formatFileSize(record.size) + '</span>';
                     desc += '</div><div class="detail">';
                     desc += '<span class="item"><em>' + scope.msg("details.description") + '</em> ' + $links($html(description)) + '</span>';
                     desc += '</div>';

Changing the desc string you can change the composition of each element listed in the document library. The object record should have all you need to show.
I try with

record.properties["MyCustomProperty"]

but I doesn't work for me… but I'm quite sure I'm close to make it works…

Hope this help.

Let me know if u can obtain better results then me.

Cheers

fiendius
Confirmed Champ
Confirmed Champ
Thanks Woody for your post!

I have found a solution for this problem, but I think it is not a clean way to get the metadata shown in documentlist. The record Object doesn't contain the metadata, so I have extended the record object with all metadata I want to display in the documentlist.
I extended the file item.lib.ftl in /alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary with my metadata records, see example below.


   <#if node.hasAspect("my:customAspect")>
      "aspectname": "my:customAspect",
      "myField": "${node.properties["{http://namespaceofAscpect}myField"]}",
   </#if>
  

Then I changed the file documentlist.js near row 1251 in /share/components/documentlibrary/documentlist.js. Here I added my new datafields aspectname and myField in the field list.


         this.widgets.dataSource.responseSchema =
         {
            resultsList: "items",
            fields:
            [
               "nodeRef", "nodeType", "type", "isFolder", "isLink", "mimetype", "fileName", "displayName", "status", "title", "description",
               "createdOn", "createdBy", "createdByUser", "modifiedOn", "modifiedBy", "modifiedByUser", "lockedBy", "lockedByUser",
               "version", "size", "contentUrl", "actionSet", "tags", "aspectname", "myField", "categories", "activeWorkflows",
            "isFavourite", "location", "permissions", "custom", "actionLabels", "onlineEditUrl"
            ],
            metaFields:
            {
               paginationRecordOffset: "startIndex",
               totalRecords: "totalRecords"
            }
         };

Now I changed the data display for example in the Simple View of the documentlist near row 967.


                 /**
                   * Simple View
                  **/
                  desc += '<div class="detail"><span class="item-simple"><em>' + scope.msg("details.modified.on") + '</em> ' +       Alfresco.util.formatDate(record.modifiedOn, "dd mmmm yyyy") + '</span>';
                  desc += '<span class="item-simple"><em>' + scope.msg("details.by") + '</em> <a href="' + Alfresco.DocumentList.generateUserProfileUrl(record.modifiedByUser) + '">' + $html(record.modifiedBy) + '</a></span></div>';
        desc += '<div class="detail">';
        if (record.aspectname == "my:customAspect"){
              desc += '<span class="item-simple"><em>' + scope.msg("details.myField") + '</em> ' + record.myField + '</span>';
              desc += '</div>'
              }

Hope this helps you to!

Bye