Search This Blog

Friday, July 19, 2013

Running liferay script on control Panel Script console

Liferay has a script console at the Control Panel. It is accessible to the Liferay administrator. In the Script console Liferay API code , and other various code can be run seamlessly.

The script console is located at

ContolPanel --> Server --> Server Administration. 






 Here are few examples of codes run in the console and screenshot of the output. Most of the  codes were run here by selecting the Language as "Groovy".

Example 1.  Get list of users

Language : Groovy
code:

import com.liferay.portal.service.UserLocalServiceUtil;

userCount = UserLocalServiceUtil.getUsersCount();
users = UserLocalServiceUtil.getUsers(0, userCount);
count=0;
for (user in users) {
    count++;
    println(count+". User: " + user.getFullName());

}





































Example 2.  Get list of roles supported be the portal.


Language : Groovy
code:

import com.liferay.portal.service.RoleLocalServiceUtil;

roleCount =RoleLocalServiceUtil.getRolesCount();
roles=RoleLocalServiceUtil.getRoles(0,roleCount );

for(role in roles){
    println("Role Name: " + role.getName());
}




Example 3.  Get number of users in the portal . (using Javascript as language default script)
Language : Javascript
code:

number = Packages.com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();

out.println(number);



No comments:

Post a Comment

My Blog List