The eccoMAGIC Forums
http://forums.eccoMAGIC.com/forum/YaBB.pl
the SLANG EXTENSION and Guest Programming >> Slangmgh: Questions, Suggestions, Requests >> Who triggered my rule?
http://forums.eccoMAGIC.com/forum/YaBB.pl?num=1195812402

Message started by JohnSmith on 11/23/07 at 04:06:42

Title: Who triggered my rule?
Post by JohnSmith on 11/23/07 at 04:06:42

Each change in Ecco is evaluated by auto-assign rules, and currently we can  even know which item has triggerd the rule. Internal variable item_id represents the current item and that is the item that triggerd the rule.
     For example the following rule puts a copy of any changed item into "Log" folder
           ++:L:          
           local vItemText=get_item_text(item_id)    
           local vNewItemID=create_item(vItemText)  
           set_folder_value("Log", vNewItemID,1)

I am just curious if it is possible to get additional info about the item which has triggered autoassign rules?
May be
     folder_id - to know in wich folder the change has been made?
     notepad_name - to know in which view the change has been made?
     item value (folder value) before the change?

Title: Re: Who triggered my rule?
Post by Admin on 11/24/07 at 11:57:15


John,


Ecco does not natively give up any of this information.  It is possible in some, perhaps many situations to cache all active item's folder values and provide an array with prior values... but... that quickly gets to be a complex task when one folder value change triggers a sequence of rules,  each changing other folder values, or mass change from group change (apply form, drag group to folder, etc.).   Ie. a lot of coding effort with maybe little actual worthwhile value.

If you want this info you can set up a second cache level for each folder,   thus you can compare and see the prior values.  (after doing so,  likely you'll want to update the cache).


eg:

Folder1  has  Folder1_C
Folder2 has  Folder2_C

etc.

or you can cache all in a single text folder,

cache looks like maybe {Folder1} ... data... {Folder2} ...data....


upon activation your L script,  can loop and compare the values (to see which has changed, and from what),  and then UPDATE the cached values with the current.



Title: Re: Who triggered my rule?
Post by JohnSmith on 11/29/07 at 08:52:19

A prior value (cache) is not so important. For me more interesting is to get and info about current folder, if this does not require special effort.

Something as current_folder_id will allow, for example, to resolve a circular reference when A=B and B=A;
or perform certain actions when an item is marked Done and do not repeat that actions when some other folder is changed.

There always is a way around of course, but current_folder_id can make it more clear.

Best regards,
JS

Title: Re: Who triggered my rule?
Post by Admin on 11/29/07 at 22:46:24

Yes,  see your point!


in the LUA context,


folder_name


will give you the folder which TRIGGERED the LUA .... ie, where the LUA is located.


but this does not tell you what folder has changed!!


to do that,  just set up the cache as suggested,  loop to compare,  and you have your answer (answers).


note: more than one folder might have been changed.....






The eccoMAGIC Forums » Powered by YaBB 2.1!
YaBB © 2000-2005. All Rights Reserved.