2

I'm trying to obtain a filename of the items of a workflow.

I try to make this:

var title;
     Alfresco.util.Ajax.jsonGet(
         {
            url: Alfresco.constants.PROXY_URI_RELATIVE + "api/metadata?nodeRef=" + nodeRefContext + "&shortQNames=true" ,
            successCallback:
            {
               fn: function(response)
               {
                  if (response.json)
                  {
                     title=response.json.properties["cm:title"];
                     alert(title);
                  }
               },
               scope: this
           },
       failureCallback:
           {
               fn: function(response)
               {
                  Alfresco.util.PopupManager.displayPrompt(
                  {
                     failureMessage: this.msg("message.failure")
                  });
               },
               scope: this
            }
         });

But gives me undefined in the alerts...

I try too with:

var nodeR = search.findNode(fileNodeRef);
alert(nodeR);

But

search is not defined

Any idea how to obtain a filename of the workflow? In the URL I only have the noderef.

PRVS
  • 1,612
  • 4
  • 38
  • 75

2 Answers2

2

You have cm:title but for the name of the file you have to access to the cm:name.

Output:

{
   "nodeRef":"workspace://SpacesStore/3444dc43-4526-4790-a63d-3827f55f53de",
   "aspects":[
      "{http://www.alfresco.org/model/rendition/1.0}renditioned",
      "{http://www.alfresco.org/model/content/1.0}versionable",
      "{http://www.alfresco.org/model/content/1.0}titled",
      "{http://www.alfresco.org/model/content/1.0}auditable",
      "{http://www.alfresco.org/model/system/1.0}referenceable",
      "{http://www.alfresco.org/model/system/1.0}localized",
      "{http://www.alfresco.org/model/content/1.0}author",
      "{http://www.alfresco.org/model/content/1.0}thumbnailModification"
   ],
   "mimetype":"application/pdf",
   "type":"{http://www.alfresco.org/model/content/1.0}content",
   "properties":{
      "{http://www.alfresco.org/model/content/1.0}autoVersionOnUpdateProps":false,
      "{http://www.alfresco.org/model/content/1.0}created":"2016-02-01T11:25:43.926Z",
      "{http://www.alfresco.org/model/content/1.0}lastThumbnailModification":[
         "doclib:1454326175307"
      ],
      "{http://www.alfresco.org/model/content/1.0}creator":"admin",
      "{http://www.alfresco.org/model/system/1.0}node-uuid":"0a790a38-2ccd-4a69-ae2f-282ebd743c26",
      "{http://www.alfresco.org/model/content/1.0}name":"examplepdf1.pdf",
      "{http://www.alfresco.org/model/system/1.0}store-protocol":"workspace",
      "{http://www.alfresco.org/model/content/1.0}content":"contentUrl=store://2016/2/1/11/29/c58f779f-f071-4d23-92d2-f38cd9f51578.bin|mimetype=application/pdf|size=94301|encoding=UTF-8|locale=en_US_|id=510",
      "{http://www.alfresco.org/model/system/1.0}store-identifier":"SpacesStore",
      "{http://www.alfresco.org/model/system/1.0}node-dbid":1231,
      "{http://www.alfresco.org/model/system/1.0}locale":"en_US",
      "{http://www.alfresco.org/model/content/1.0}versionLabel":"1.1",
      "{http://www.alfresco.org/model/content/1.0}modifier":"admin",
      "{http://www.alfresco.org/model/content/1.0}modified":"2016-02-01T11:29:34.763Z",
      "{http://www.alfresco.org/model/content/1.0}autoVersion":true,
      "{http://www.alfresco.org/model/content/1.0}initialVersion":true
   }
}

You can see "examplepdf1.pdf" is the name of the file and the property is name instead of the title.

So, instead of this:

title=response.json.properties["cm:title"];

put this:

title=response.json.properties["cm:name"];
Fabian N.
  • 3,807
  • 2
  • 23
  • 46
JMR
  • 765
  • 1
  • 8
  • 31
1

By inspecting the output of that particular webscript

GET http://127.0.0.1:8080/alfresco/s/api/metadata?nodeRef=workspace://SpacesStore/5ad08b31-482f-41b1-8949-8021dd455507

, I found that it is formatted like this:

{
   "mimetype":"application/octet-stream",
   "aspects":[
      "{http://www.alfresco.org/model/content/1.0}auditable",
      "{http://www.alfresco.org/model/system/1.0}referenceable",
      "{http://www.alfresco.org/model/content/1.0}titled",
      "{http://www.alfresco.org/model/content/1.0}taggable",
      "{http://www.alfresco.org/model/system/1.0}localized",
      "{http://www.alfresco.org/model/content/1.0}generalclassifiable"
   ],
   "nodeRef":"workspace://SpacesStore/5ad08b31-482f-41b1-8949-8021dd455507",
   "properties":{
      "{http://www.alfresco.org/model/content/1.0}name":"aa",
      "{http://www.alfresco.org/model/system/1.0}node-dbid":769,
      "{http://www.alfresco.org/model/system/1.0}store-identifier":"SpacesStore",
      "{http://www.alfresco.org/model/system/1.0}locale":"fr",
      "{http://www.alfresco.org/model/content/1.0}title":"",
      "{http://www.alfresco.org/model/system/1.0}node-uuid":"5ad08b31-482f-41b1-8949-8021dd455507",
      "{http://www.alfresco.org/model/content/1.0}taggable":null,
      "{http://www.alfresco.org/model/content/1.0}modified":"2016-01-12T10:22:17.437+01:00",
      "{http://www.alfresco.org/model/content/1.0}created":"2016-01-12T10:22:17.437+01:00",
      "{http://www.alfresco.org/model/system/1.0}store-protocol":"workspace",
      "{http://www.alfresco.org/model/content/1.0}creator":"admin",
      "{http://www.alfresco.org/model/content/1.0}description":"",
      "{http://www.alfresco.org/model/content/1.0}categories":null,
      "{http://www.alfresco.org/model/content/1.0}modifier":"admin"
   },
   "type":"{http://www.alfresco.org/model/content/1.0}folder"
}

So I suggest you try title=response.json.properties["http://www.alfresco.org/model/content/1.0}title"];

instead of title=response.json.properties["cm:title"]; !

Younes Regaieg
  • 4,156
  • 2
  • 21
  • 37