Create an event based on how many times an action has occurred?

Hi,

This is really just to get a general idea on the best method to pursue.

If a user changes the status from ‘Whatever’ to ‘Complete’

Can I trigger and event to happen every ‘X’ amount of times the status is changed to ‘Complete’

  • So the application is counting the status changes
  • When ‘X’ is reached it triggers an event
  • Then resets the counter so the process can continually repeat

Any help appreciated…

Hi,

Should be fairly trivial (assuming only one or two fields are affected).
Add an additional Integer field to your object say status-update-count.

Create a rule with a trigger of “fields updated” and choose the status field. Action is to increment field value - choose status-update count.

Create a subset with predefined filter of status-update-count >= X on the object (where X is the count you need)

Create a rule with trigger event “Added to subset” on your new subset, that fires your event.
Create a second rule with same trigger event to clear down the update count if you want it to happen again…

Richard

Thanks for the starting point @richk

Like this? @richk


Looks good to me - probably worth adding the count to some page somewhere initially so you can be sure it is being updated (and remove it once you are happy).

@richk - Great news. The counter works which is nice.

What would be the best best to ‘group the counter so its based on the user’ that did that status change only.

At the moment each request seems to have its own counter

That’s tough. - You would need one counter per user per “Request for Evidence”. The only way you could do that would be to have a bridging object with a single field being the counter and you would need many 2 one relationships to both the user and the Request.

I am sure there is another way to do it, but the only ‘standard’ one that comes to mind is whenever you create a user you create a bridging object with a relation to all existing Requests - and similarly whenever you create a Request you create a bridging object to all existing Users - and I suppose when you delete a user, you delete all related bridging objects (and similarly for Requests! More than a few rules!

The other way would be with a custom event processor that created the bridging objects and relationships either as above, or only when a user updated the field the first time!

Hi @richk

Added the new object and linked.

I can see the counter is working but it seems to be shared between all users.

3

Here is the rule used to associate the relationship.

Not sure if I selected the right action or wrong relationship path

Don’t think I can see what is happening here. Can you create a list of Audit counter objects somewhere on a debug page and in include the count of the number of related users and the count of the number of related Requests - and check they match the number of users and number of requests on your system. I suspect you are creating a 1-to-1 to the audit object then a 1-2-many to the users If nothing obvious from that, then PM me with contact details and we can sort out a screen share next week.