Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
Tinderbox Users >> Agent, Actions, Rules & Automation >> A One Time Action

Message started by Ted Goranson on Jan 13th, 2015, 10:54pm

Title: A One Time Action
Post by Ted Goranson on Jan 13th, 2015, 10:54pm

I'm trying to get my trivial action code load down to allocate resources to actions that will be heavier. Many of these "trivial" actions set the state of notes in progress and get set once in the life of a note, yet the code gets evaluated thousands of times a day.

So what I am striving for is a general one-time trigger, something like a stamp but triggered by checking a boolean key attribute once.

For example, suppose we had a KA $IsDone that was boolean. When I think a note is ready to publish, I click this. Among other things, it invokes a stamp by name (that for instance changes the badge) and at the end of the stamp resets that KA to false.

I'm sure someone has figured this out, and I may have even read about it but forgotten.


Title: Re: A One Time Action
Post by Mark Anderson on Jan 14th, 2015, 3:22am

Since v5.10.2, Stamps can no longer be called via Action code so using stamps in an automated fashion.

I think the best approach is to use a guard attribute, such as the Boolean $IsDone that you describe. Then the rule is:

if($IsDone==false) {
  ...lots of code, finishing by setting $IsDone to true...

Although the rule is run constantly, the code within the if() test is only run for notes whose $IsDone has not yet been set to true. If the conditional code, when run, finishes by setting $IsDone to true then the big chunk of code is only ever run once on a note (unless $IsDone is manually reset to deliberately re-trigger the process).

Whilst lots of rules will have a seemingly large section of code, in most notes all that will occur is a simple Boolean test that results in no outcome and thus not loading the the rule cycle.

Separately, in the v6 context (I realise you’re still using v5) there has been discussion on ‘run once’ or ‘run at some low frequency event’ type rules or agents. At this point, it is still discussion but I think is a move better - or simpler - support of scenarios like the one you describe.

If you don’t want to use a rule like that described then store the code is a stamp and and use some visual tell-back to indicate those notes that need the stamp applied. I was going to also suggest an agent but that leads the user to stamping aliases and not originals in which case extra care needs to be taken with the stamp code to ensure original and not intrinsic alias attributes are changed.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.