cancel
Showing results for 
Search instead for 
Did you mean: 

cant use the Root Scope Objects in JS

schurik
Champ in-the-making
Champ in-the-making
Hello,

i have a Problem with the JavaScript API. I used this Example (http://code.google.com/p/share-extras/wiki/ExecuteScriptAction). When i use one Root Scope Objects like logger.log("") or actions.create(""), i get this Error in the JavaScript console:

actions is not definied

can somebody help me with that Problem?

Ty

Alex
3 REPLIES 3

pmverma
Champ in-the-making
Champ in-the-making
schuric,
I think there is no logger object but i am not sure if there is.But for
actions.create("")
, it must works.

Because you say you get error
actions is not definied
, here I do not in which kind of JavaScript file you are using this object.

I think the following links will points what you like to do.They are used from javascripts to manipulate repository.

http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FAPI-JS-ro...

http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FAPI-JS-Se...

P. M. Verma

schurik
Champ in-the-making
Champ in-the-making
Hi verma,

thank you for your answer. I was in the wrong js-file, that was the client-side js-file. The server-side JS is new for me, i have no experience with that.

In my simpleDialog i have a button "search", when i click on them it must run a java-method, that return a list with the search-results. The JS-file that create the simpleDialog is client-side, so i cant run the java-methode. How i can realize that? If you have code-snippets, it would be very nice.

Thank you

pmverma
Champ in-the-making
Champ in-the-making
Hi schurik,
you said,
In my simpleDialog i have a button "search", when i click on them it must run a java-method, that return a list with the search-results.
So, I think you should have a better understanding how the Alfresco Repo side + Share work. you can google and find topics.
As for now,very simple flow,
When you click search button, then your client side js make a call to repository side webscripts with appropriate url and parameter (if needed).

Then, the webscripts at repository side make some manipulation as requested from your client-side js files. In this repository side webscripts, you have a js file in which you can use Javascripts API methods such as (which i copy and paste from my webscripts)

1. var person = people.createPerson(userName, json.get("firstName"), json.get("lastName"), json.get("email"), password, enableAccount);
2. people.getGroup(groupId);
3. var peopleCollection = people.getPeople(filter, maxResults != null ? parseInt(maxResults) : 0);
4. var person = people.getPerson(userName);

After then it response  back to Share side. In client side js you can see following user.js
Alfresco.util.Ajax.request(
            {
               url: Alfresco.constants.PROXY_URI + "api/people/" + encodeURIComponent(parent.currentUserId) + "?groups=true",
               method: Alfresco.util.Ajax.GET,
               successCallback:
               {
                  fn: success,
                  scope: parent
               },
               failureMessage: parent._msg("message.getuser-failure", $html(parent.currentUserId))
            });
From user.js, A request is made to repository side webscripts with url. This will retrieve the user's details from repository side to your users.js

I think you can do something like this on your button click.

For a better seeing server-side js, you could see in your webscripts in "webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco".
But this is some only for looking into its working.

P. M. Verma