Node templates by Site in Alfresco

Alfresco provides a feature to set files as templates. However, every file uploaded to Repository > Data Dictionary > Node Templates will be available as template for every user in every site.

Let’s see how can we tweak permissions in order to have different templates for different sites.

Initial situation

We are using two sites in this sample with following properties:

  • Accounting and Finance
    • Short name: accounting-and-finance
    • Internal group name: GROUP_site_accounting-and-finance
    • Required template: CV.docx
  • Purchasing
    • Short name: purchasing
    • Internal group name: GROUP_purchasing
    • Required template: PO.xlxs

Both CV.docx and PO.xlxs files are uploaded to Repository > Data Dictionary > Node Templates by using Share uploading feature.

Manage Permissions

As Share web interface does not expose internal groups to actions, it’s required to use a tool like JavaScript Console to make this setting.

For document CV.docx following sentences are executed:

document.setPermission("Read", "GROUP_site_accounting-and-finance");
document.save();

For document PO.xlxs following sentences are executed:

document.setPermission("Read", "GROUP_site_purchasing");
document.save();

After executing these operations, regular Manage Permissions action is used to unset Inherit Permissions.

Testing

From this point users from site Accounting and Finance will only have available CV.docx from Create document from template option and users from site Purchasing will only have available PO.xlsx from Create document from template option.

This is a so simple approach, that I’ve been internally forced to create a new addon available at https://github.com/keensoft/alfresco-site-node-templates

Check it out!

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s