Trigger "When items are updated" rule when editing associations only

cancel
Showing results for 
Search instead for 
Did you mean: 
cseickel
Customer

Trigger "When items are updated" rule when editing associations only

Jump to solution

I've recently discovered that folder rules that run when "items are updated" do not fire if the only update is an association change.  I need these rules to run on association changes too.  Has anyone come up with a work around for this limitation, or is there a configuration I can make to enable the behavior I am looking for?  

I don't actually need the associations, I am only using them as a way to get a nice "Select a folder" control in Share.  The associations are then used by JavaScript rules to copy certain properties from the associated folders.

I am running 6.0 enterprise.

Thank you for any help you can provide.

-Chris

1 Solution

Accepted Solutions
cseickel
Customer

Re: Trigger "When items are updated" rule when editing associations only

Jump to solution

As it turns out, Alfresco the entire premise for this question was wrong.  Alfresco should fire the update rule when you edit an association and it does under most circumstances.  The fact that it sometimes does not turns out to be a bug that I am experiencing.  At this moment, I don't know how to recreate it but I will update the question when I do find out.

View solution in original post

5 Replies
jpotts
Professional

Re: Trigger "When items are updated" rule when editing associations only

Jump to solution

Hi Chris,

Have you considered writing a behavior that would bind to one or more of the following Node Service Policies:

onCreateAssociation
onCreateChildAssociation
onDeleteAssociation
onDeleteChildAssociation

Jeff

cseickel
Customer

Re: Trigger "When items are updated" rule when editing associations only

Jump to solution

Hi Jeff,

Yes, I considered that I might have to use behaviors in the end, but I was looking to see what other solutions where possible before going down that route.  For example:

  1. Is there a way to configure the system so that association changes trigger the Update rule?
  2. Is there a way to use a folder picker in a property but then save a property of the selected node instead or in addition to creating an association?  This would work around the limitation.

One concern I have about using associations is that it seems like the code could run multiple times for one node edit.  What if someone edits a node and deletes two associations, adds two associations, and edits a property?  If I bind to the onCreateAssociation, onDeleteAssociation, and the equivalent for properties, will my code be called 5 times?  If so, is there a way to buffer these events so that I run a block of code no more than once per transaction?

I can separate property change logic from the association change logic, but all of the association changes must be treated as a set and handled once per edit.

Thank you,

Chris

jpotts
Professional

Re: Trigger "When items are updated" rule when editing associations only

Jump to solution

Is there a way to configure the system so that association changes trigger the Update rule?

No, there is no out-of-the-box way to do this.

Is there a way to use a folder picker in a property but then save a property of the selected node instead or in addition to creating an association?  This would work around the limitation.

Not that I know of. You could, of course, write your own control and picker.

...is there a way to buffer these events so that I run a block of code no more than once per transaction?

You can try setting your behavior to bind on TRANSACTION_COMMIT instead of FIRST_EVENT or EVERY_EVENT. A single edit should be part of the same transaction.

cseickel
Customer

Re: Trigger "When items are updated" rule when editing associations only

Jump to solution

I guess behaviors are really the way to go then.  Thanks for your help.

cseickel
Customer

Re: Trigger "When items are updated" rule when editing associations only

Jump to solution

As it turns out, Alfresco the entire premise for this question was wrong.  Alfresco should fire the update rule when you edit an association and it does under most circumstances.  The fact that it sometimes does not turns out to be a bug that I am experiencing.  At this moment, I don't know how to recreate it but I will update the question when I do find out.