I've written a few times about business rules in Priority, and it seems that thinking about these rules has opened up a few possibilities. A business rule is inclusive: one defines for which users (or groups) the rule is effective. This sometimes means that the same rule has to be defined several times, once for each group of users. There is no way of defining a business rule to be exclusive, i.e. it applies to everyone except a few users.
... Or is there? After a little creative thinking, I realised that I could define an exclusive rule. The way to do this is to define one of the three conditions that business rules allow in the following manner: the document's date is equal to the following function:
(SQL.USER IN (1, 205) ? 01/01/88 : :$.CURDATE)
This piece of gibberish, when translated in English, means that if the current user's number is 1 or 205 (1 is the system manager, 205 is my user number), then return the value 01/01/88, else return the document's date. If the current user's number is 6, then the condition will be true (document date = document date) and so the business rule applies to this user. If the current user's number is 205 (i.e. me) then the condition will be false, and so the business rule will not apply to me.
Convoluted logic, but it works. The only problem with this is that the above uses one of the business rule's three conditions, and there may not be a condition to spare. It might be possible to chain the above logic, but I suspect that it won't work.
1 comment:
I've made widespread use of this trick since you've brought it up.
I've expanded on it by using it in the web interface which allows a (supposedly) unlimited number of conditions, and for you to set the relationship of all the conditions to be either AND or OR. The limit I've run into is that you're limited to the 120 characters of the VALUE column in the FORMALERTCONDS table. This gets used up quite quickly, since once you start nesting your AND and OR conditions, the expression length can blow right up. I'm currently testing the consequences of expanding the column width in the table, see if I can't squeeze just a little more logic in there.
Post a Comment