Change values of properties included in ‘cm:auditable’ aspect: cm:creator, cm:modifier, cm:created, cm:modified, cm:accessed in Alfresco


Values of fields defined in cm:auditable aspect can not be easily changed in Alfresco. The reason for it is that they are automatically generated and whenever user tries to change the value it gets overwritten. This post provides solution that allows to change values of the following properties:

  • cm:creator
  • cm:modifier
  • cm:created
  • cm:modified
  • cm:accessed


Let’s assume that we defined behaviour that changes values of cm:creator and cm:modifier whenever its value is changed. The logic to do so is implemented in onUpdateProperties method. To change the values first behaviour related cm:auditable aspect has to be disabled, then values have to be changed and then the behaviour has to be enabled. It is presented in the code below.

public class ChangeAuditablePropertiesBehaviour implements NodeServicePolicies.OnUpdatePropertiesPolicy { 
    // Dependencies
    private PolicyComponent policyComponent;
    private BehaviourFilter policyBehaviourFilter;
    // Behaviours
    private Behaviour onUpdateProperties;
    public void setPolicyComponent(PolicyComponent policyComponent) {
        this.policyComponent = policyComponent;
    public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter) {
        this.policyBehaviourFilter = policyBehaviourFilter;
    public void init() {
        // Create behaviours
        this.onUpdateProperties = new JavaBehaviour(this, "onUpdateProperties", Behaviour.NotificationFrequency.TRANSACTION_COMMIT);
        // Bind behaviours to node policies
        policyComponent.bindClassBehaviour(NodeServicePolicies.OnUpdatePropertiesPolicy.QNAME, ContentModel.TYPE_CONTENT, onUpdateProperties);
    public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) {
        // Disable auditable aspect to allow change properties of cm:auditable aspect
        policyBehaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
        // Update preferences of cm:auditable aspect
        setProperty(nodeRef, ContentModel.PROP_CREATOR);
        setProperty(nodeRef, ContentModel.PROP_MODIFIER);
        // Enable auditable aspect
        policyBehaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);

Bean definition:

    <bean id="changeAuditablePropertiesBehaviour" class="com.jmuras.ChangeAuditablePropertiesBehaviour" init-method="init">
        <property name="policyComponent" ref="policyComponent" />
        <property name="policyBehaviourFilter" ref="policyBehaviourFilter" />
  1. Great series of tutorials on Alfresco. Thanks

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">