Latest technology news, trends and developers guide for business application. Visit this space for more tech updates.

Let’s work on your exciting new project together!

Run Javascript Function as Admin Privileges

alfresco, javascript

  • In Alfresco, create group, user, add user to group, set permission are allowed only to Admin group users.
  • Many times we get a requirement where we need to create group and users dynamically on some action.
  • Now javascript API are available to create group but works only for Admin group users.
  • I had a requirement to create groups dynamically when rule is executed. But rule was executed action taken by non-admin user.
  • So I created custom javascript API to run entire javascript function as Admin privileges.
  • For this you have to create one Java class which extends BaseScopableProcessorExtension. BaseScopableProcessorExtension class is extended whenever you want to create custom javascript API.
  • Register your javascript API in *-context.xml
  • Then use your API in your javascript.

public class RunAsAdminUtil extends BaseScopableProcessorExtension {
* This method runs javascript function with Admin privileges
* @param func
public void runAsAdmin(final Function func) {
final Context cx = Context.getCurrentContext(); final Scriptable scope = getScope();
RunAsWork raw = new RunAsWork() {
public Object doWork() throws Exception {, scope, scope, new Object[] {}); return null;
Below is the *-contex.xml entry,


Below is the code of javascript where you would be using custom created javascript api to run function with admin privileges

function main() { if (!people.isAdmin(person)) { //if current logged in user is not admin run function with admin privileges runAsAdminUtil.runAsAdmin(createGroupsDynamically); }else{ createFolderStructureFromTemplate(); } } var createGroupsDynamically = function createGroupsDynamically() { var name =; var TEST_READ = name + '_read'; var TEST_WRITE = name + '_write'; people.createGroup(TEST_READ); people.createGroup(TEST_WRITE); } main();

Alfresco Integration With SalesForce

Introduction: We will connect two important aspects of the business, Customer Relationship and Customer/Vendor Documents....

Google Uncovers Angular 5 JavaScript and Here’s what It Promises

Google has unleashed the Angular 5 after two major upgrades in less than last 2...

8 Valuable Tips to Master Best Code Practices in Node.JS

As one of the most popular open source platforms for developing server applications, Node.JS has...

Subscribe to our Newsletter Receive free e-guides, news, updates and more