cancel
Showing results for 
Search instead for 
Did you mean: 

Get filename of workflow with javascript - Alfresco

pat9rv3sousa
Champ on-the-rise
Champ on-the-rise
I'm trying to obtain a filename of the items of a workflow.

I try to make this:

<javascript>
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
            }
         });
</javascript>

But gives me <cite>undefined</cite> in the alerts…

I try too with:

<javascript>
var nodeR = search.findNode(fileNodeRef);
alert(nodeR);
</javascript>

But

search is not defined

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

muralidharand
Star Contributor
Star Contributor
search is defined in Alfresco Server side javascript and you can't get them in client side javascript.

Alfresco Repository JavaScript API reference details are here, http://docs.alfresco.com/5.0/references/API-JS-rootscoped.html

niketapatel
Star Contributor
Star Contributor
If I understand correctly You want to get filename on which workflow has been initiated. Your code snippet looks OK but make sure title property is defined
for given nodeRef else it will give undefined.

You can also test by hitting direct metadata URL and check if title is available in response -  alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/bc40148c-0e85-484d-a6f3-c97329183d3f&shortQNames=true