cancel
Showing results for 
Search instead for 
Did you mean: 

Request in Alfresco database

cyr
Champ in-the-making
Champ in-the-making
Hi, i am really new in alfresco and
I am having problems to make requests in alfresco database.
i am using alfresco 4.0.2 and a postgresql database
I followed this tutorial: http://wiki.alfresco.com/wiki/3.4_JavaScript_API,and created a simple js file for the request.

function requestSearch(){
var nodes = search.luceneSearch("TEXT:alfresco");
return nodes;
}

$(function() {

$("#articles").click( function(){
alert( requestSearch());
});
});
with just a simple request to display alfresco text.
but it doesn't work, and when i debug, an error is shown at the import of librairies.
i checked the location of theses libraries files in "/Company Home/Data Dictionary/Scripts/, but they don't exist in that location and i didn't manage to find where they are.
Does anyone know where are they located?
or am i on the wrong way to make requests in database
Thx
5 REPLIES 5

mitpatoliya
Star Collaborator
Star Collaborator
You are using this wrongly. You are using it as normal client side javascript but this functions are of alfresco javascript and you would be able to execute them on server side only.
So you need to first created independent script using those apis as shown in cookbook.
Test it by uploading them under script folder in alfresco then run action to execute that script.
Then you can hook that script with any of rule in alfresco.

cyr
Champ in-the-making
Champ in-the-making
Thank you for your advice, it is a little bit clear now but not quite clear.
Can i have one clear example or tutorial to make it work?
Thanx

kaynezhang
World-Class Innovator
World-Class Innovator
In your code

$(function() {
$("#articles").click( function(){
alert( requestSearch());
});
});

which is is client-side JavaScript ,it will only run in your browser.

But the import command and search object should be ran in server side and executed in the alfresco repository context

cyr
Champ in-the-making
Champ in-the-making
Thank you kaynezhang, your post was really helpful, and i know now what path to take.
but i still facing a problem, i followed this tutorial about creating a JS server-side script ( http://www.packtpub.com/article/alfresco-3-writing-executing-scripts ).
i loggedin as admin and i created a JS file (transform.js) in the script Folder under company home. but when i try to run my script, et when i reached the "select a script to execute", i don't see my script in the dropdown box. i restarted the server, but still nothing.
Am i missing something?

thanks in advance!

kaynezhang
World-Class Innovator
World-Class Innovator
Make sure your js file is placed  under /Company Home/Data Dictionary/Scripts and make sure you transform.js's mime type is "Java Script"
If  the content type is plain text or html. It won't be seen .

you can edit the content type to javascript  by clicking "View Details" and click "Modify"