cancel
Showing results for 
Search instead for 
Did you mean: 

Discover updated properties on rule service executed action.

iblanco
Confirmed Champ
Confirmed Champ
When you set a rule for inbound content it fires whenever content is added or updated.

I can "manage" to detect if it is a new content by comparing creation and modification dates of the content, but is this a safe way of doing so ? Although not very probable it is technically possible for a content to be updated in less than a second, and that would be considered a creation. Besides AFAIK there is no warranty that Alfresco's code will use the same date for both properties, so in some cases the creation and modification dates could vary even on a creation operation.

Besides knowing if it is an update or not it would be very useful being able to know what properties have been updated. I know there is an easy way to do so in the behaviours but is there any similar way of achieving the same in an action executed from a rule?

Thanks.
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
No I don't think there is an easy way to determine what has changed through rules.

And, as you suspect, you can't rely upon modification dates since they are only approximate to about a second. Smiley Sad

As you point out there are behaviours that will allow you to determine what has changed.   Do you actually need to use a rule for your piece of functionality, can you not just use a behaviour?

iblanco
Confirmed Champ
Confirmed Champ
Well, what I want to achieve is "location" related, not "type" related. I want to create some entries in a Share Site's discussion board when a content is created/updated in it's document library.

AFAIK behaviour's execution (class policies at least) are constrained based on the node's type or aspect so in order to achieve my goal I would have to bind the policy to "cm:content" and then, in the behaviour decide if the created node is related to a site that requires notification or not. That seems like a very bad and overkill idea, isn't it ? Instead I managed to programatically add a rule at site-creation time that fires on "inbound" events.

Maybe I could instead do it like this:

- Add a rule to the document library that on create adds a custom "notifyToForum" aspect
- Add a behaviour that fires on "onUpdateProperties" of the "aspect". ( I think this property fires even on creation time, but that should be easy to detect when this happens based on the previous properties map )
- Add a behaviour that fires on "beforeDeleteNode" of the "aspect", to notify the deletion of a file.
- Add a behaviour that fires on "onCreateVersion", although probably the creation of a new version also fires  "onUpdateProperties" and this won't be neccesary.

Does it make sense ? I'll give it a try this afternoon.