Welcome, Guest. Please Login
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
Pages: 1
Send Topic Print
A One Time Action (Read 1331 times)
Ted Goranson
Full Member

Posts: 141
Virginia Beach VA
A One Time Action
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.

Back to top
WWW TedGoranson   IP Logged
Mark Anderson
YaBB Administrator

User - not staff!

Posts: 5689
Southsea, UK
Re: A One Time Action
Reply #1 - 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.
Back to top

Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print