cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve document based on custom property

deepacp
Champ in-the-making
Champ in-the-making
Hi,

I am writing a webscript that retrieves a document based on the custom property "shortLink". I am using the code given below to retrieve the node

      var searchQuery = "@vmr\\:shortLink:\"" + documentShortLink + "\"";
      // perform search
      var nodes = search.luceneSearch(searchQuery);

It is unable to find the node. However, I was able to retrieve it by searching for "vmr:shortLink:e91bf03f-328e-457e-a21f-45b4049cc619" on Alfresco Share.

I am new to Alfresco and hence maybe missing something very trivial. Please guide me on where I could have gone wrong.

Thanks
Deepa
3 REPLIES 3

douglascrp
World-Class Innovator
World-Class Innovator
That should work.
Have you tested your query using nodebrowser?
Do you get any error messsage on the logs when you run you query?

deepacp
Champ in-the-making
Champ in-the-making
Thanks! I tried with Node Browser too and it gives me the document. I didn't find any error messages in the logs. It just returns a null value.
I tried implementing the same using Java backed webscripts and it worked fine. I still don't understand why it fails from javascript.

kaynezhang
World-Class Innovator
World-Class Innovator
Have you tried to encode it using ISO9075-encoded format ?

var searchQuery = "@vmr\\:shortLink:\"" + documentShortLink + "\"";
var encodedString = search.ISO9075Encode(searchQuery);
var nodes = search.luceneSearch(searchQuery);