cancel
Showing results for 
Search instead for 
Did you mean: 

search root object not functioning

hammerguy
Champ in-the-making
Champ in-the-making
Hi

I am using the "search" root object in javascript that execute in the Alfresco web client (specifically: object-finder-min.js).
My code line goes like this:

var node = search.luceneSearch("ID: \"workspace://SpacesStore/1fb68100-cf63-4e96-b366-0ecefc28cdca\"");

When I debug my code, I get to this line and it blows up, without displaying any error in firebug.

Anybody has a clue?
thx
1 REPLY 1

parzgnat
Star Contributor
Star Contributor
There is a distinct difference in Alfresco between client-side JavaScript and server-side JavaScript.  The file that you're referencing (object-finder-min.js) is a client-side JS file.  It executes in the browser the way that you're used to in most web applications.  The root objects (including "search") are only available when writing server-side JavaScript.  Most often, Alfresco server-side JS is used when writing custom web scripts.  At the end of the day, server-side JavaScript is translated into Java code and runs on the server.  The advantage of writing web scripts using server-side JS instead of Java is that updates can be deployed without a full server restart.

In your case, if you need to run a search and then display the results in the user interface, your client-side JS should be making an AJAX call to either an out-of-the-box Alfresco web script, or you can write a custom web script if the out-of-the-box services don't meet your needs.  There is no way to directly access the repository through client-side JS.  You need to make AJAX calls to server-side services.

Here are some additional resources:
Server-side JS: http://wiki.alfresco.com/wiki/4.0_JavaScript_API
Web Scripts: http://wiki.alfresco.com/wiki/Web_Scripts