Thursday, January 04, 2018

Business rules in Priority which do not apply to specific users

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) ? 'A' : :$.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 'A', 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.

No comments: