cancel
Showing results for 
Search instead for 
Did you mean: 

search.findNode() is not working

sans
Champ in-the-making
Champ in-the-making
Hi,
I am trying to modify My-tasks page. I am editing the share\components\workflow\task-list-min.js.
I want to display Site Name, file name, Initiator, Start date apart from the existing fields such as Due:, Status: and Type:.
I have all the values that I need to display. I have bpm_context and bpm_package. But the value that is displayed is workspace://SpacesStore/221241f0-bc8c-4202-b780-456f799470f1. Now I want to extract folder name and site name from this value.
I know this url represents the folder name. I am trying to use the search.findNode(workspace://SpacesStore/221241f0-bc8c-4202-b780-456f799470f1). But the issue is I am getting a java script error, search is not defined.
I know that search is available on alfresco side but not on share side. Is there any way to enable it on share side? Or is there any other work around for this?
Please help!!

Thanks
Sanjay!!
9 REPLIES 9

mikeh
Star Contributor
Star Contributor
The Surf web tier has no concept of nodes, aspects, properties, etc. - you'll need to use a repository webscript, e.g.
remote.call("/api/metadata?nodeRef=" + nodeRef)
That will return a JSON structure with the node's properties.

Thanks,
Mike

sans
Champ in-the-making
Champ in-the-making
Hi Mike,
Thanks for the quick reply.
As per your suggestion I am using
remote.call("/api/metadata?nodeRef=" + nodeRef)
in the task-lits-min.js. But I am getting "remote is not defined" error.
Please help!!

Thanks
Sanjay!!

mikeh
Star Contributor
Star Contributor
You were trying with browser-based JavaScript? No wonder it didn't work! The "remote" object is part of the Surf API - i.e. it needs to run on the web server.

If you want this to be requested from the web browser, you'll need to use an AJAX request. Have a look at Alfresco.util.Ajax.jsonGet in alfresco.js

Mike

sans
Champ in-the-making
Champ in-the-making
Hi Mike,
Thanks for the reply. I will look into it and get back to you if any issues/questions.

Thanks
Sanjay!!

sans
Champ in-the-making
Champ in-the-making
Hi Mike,
Regarding the problem that I am facing…

I looked at the jsonGet in alfresco.js. In my javascript i am calling the jsonGet method and I am getting successful result. In the fire bug I can see the response and the data. It shows me folderName as well. But I need to extract the values from the response.
I tried to use myObject.getData("properties")["{http://www.alfresco.org/model/content/1.0}title"]. But I am getting error on getData method.
Here is code snippet
    Alfresco.util.Ajax.jsonGet(
         {
            url: Alfresco.constants.PROXY_URI_RELATIVE + "api/metadata?nodeRef=" + nodeRefContext ,
            successCallback:
            {
               fn: function(response)
               {
                  if (response.json)
                  {
                     var json=response.json;
                     json.getData("properties")["{http://www.alfresco.org/model/content/1.0}title"];
                  }
               },
               scope: this
           },
      failureCallback:
           {
               fn: function(response)
               {
                  Alfresco.util.PopupManager.displayPrompt(
                  {
                     failureMessage: this.msg("message.failure")
                  });
               },
               scope: this
            }
         });
Also how do I return the results of a ajax request?

Please help!!

Thanks
sanjay!!

mikeh
Star Contributor
Star Contributor
response.json.properties["{http://www.alfresco.org/model/content/1.0}title"]
If you prefer you can add &shortQNames=true to the URL so then you could get the title from
response.json.properties["cm:title"]

Thanks,
Mike

sans
Champ in-the-making
Champ in-the-making
Mike,
Great Stuff!! It worked!! You Rock!!
One quick question.
How do i get the details in the caller method? I am getting the title as undefined. But if I print it inside method it prints the value.
here is the code snippet.
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"];
           console.log(title);
        }
               },
               scope: this
           },
      failureCallback:
           {
               fn: function(response)
               {
                  Alfresco.util.PopupManager.displayPrompt(
                  {
                     failureMessage: this.msg("message.failure")
                  });
               },
               scope: this
            }
         });
    console.log("title "+this.title);

Please help!!

Thanks
sanjay!!

mikeh
Star Contributor
Star Contributor
It's an asynchronous request with a callback function. Your console.log command is executing before the response has been parsed.

If none of that makes sense, you need to do some reading up on JavaScript and AJAX.

Thanks,
Mike

sans
Champ in-the-making
Champ in-the-making
Thanks Mike!!!
Now I can show Site Name, Initiator, Owner, and Folder Name on my tasks page.
I also want to show the file name which is part of the workflow.
I have bpm_package. How can I get the file name from this?

Please help!!

Thanks
sanjay!!