cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to detect which event triggered a folder rule?

pedwards99
Star Contributor
Star Contributor

Hi there,

I have a rule on a folder that executes some custom javascript.

The rule is triggered:

"When items are created or enter this folder"

and

"When items are updated"

I want my script to behave slightly differently for each event.

Does anyone know if it is possible to detect which event triggered the script or do I need to create 2 separate rules and scripts?

Thanks

Paul

4 REPLIES 4

mehe
Elite Collaborator
Elite Collaborator

Hi Paul,

I don't think there is a handle or something else for the triggering event, but you can set/check a special property on the triggering object. For example a document action triggers the event,

  • test if your property or aspect is already set
  • if not - it's a new doc (meaning onCreate event), so set your property
  • if already set it's a update/change event

you could also check the modified an created date time - if modified is newer than created, it was a update/change event. (if created is newer than modified, shut down your whole network Smiley Happy )

Maybe thats more work than to handle two separate events... but...

regards,

Martin

douglascrp
World-Class Innovator
World-Class Innovator

Or another option would be to use behaviors instead, and then you will be able to detect what caused the execution, and even more details like, the properties that got changed, including the before and after values.

Thanks Douglas

pedwards99
Star Contributor
Star Contributor

Thanks Martin