Errors (Warnings) on resolving values

If you think that something doesn't work in Aware IM post your message here
Post Reply
ckacoroski
Posts: 58
Joined: Mon Nov 13, 2006 9:15 pm
Location: Bothell, USA

Errors (Warnings) on resolving values

Post by ckacoroski »

Hi,

I have two reference attributes on my object (one called Services_Add and one called Services_Del). I have a rule that assures that you can not have a reference to the same service in both attributes like so:

If Services was added to Staff.Services_Add and AddedServices in Staff.Services_Del then
report error 'Cannot have same service in both Services_Del and Services_Add'
else if Services was added to Staff.Services_Del and AddedServices in Staff.Services_Add then
report error 'Cannot have same service in both Services_Del and Services_Add'

This works ok, but I get these errors in the log:

Value of Services could not be resolved
Unable to resolve facts fro the following pattern IN expression for object Staff.Services_Add null

I think what is happening is that this rule is being run when nothing is added to Services_Add or Services_Del which means that AddedServices is null which is throwing the error in the log.

This seems to work ok even with the error, but is there a way to write the rule so I do not get the errors. What I was hoping for is that the engine will stop checking a rule once one of the facts is false (e.g. shortcut), but it seems to check all facts even though the first fact 'Services was added to Staff.Services_Add' is false (e.g. I change some other attribute on the object and I see the errors).

thanks for your help.

ski
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

Hi ski,

Instead of using "else", try breaking this rule into two separate rules as it checks for two independent events.
Aware IM Support Team
ckacoroski
Posts: 58
Joined: Mon Nov 13, 2006 9:15 pm
Location: Bothell, USA

Post by ckacoroski »

No luck. I still get the errors. I think what I need is a nested If so the rule does not attempt to access the AddedServices variable when no services were added (or the rule engine needs to shortcut rules so if the first fact was false, it doesn't check the other facts).

What should I try next?
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

ski,

I wonder if you could use a different approach and have 2 rules which are variants of the "Uniqueness of login name" rule in the RegularUser BO?

If EXISTS...... WHERE .......

Tom
ckacoroski
Posts: 58
Joined: Mon Nov 13, 2006 9:15 pm
Location: Bothell, USA

Post by ckacoroski »

Thanks Tom, This worked for the rule that reports the errors as I rewrote it to be:

If EXISTS Services where (Services in Staff.Services_Add and Services in Staff.Services_Del) then
report error 'Cannot have same service in both Services_Del and Services_Add'

Now I have a problem with the rule for adding/deleting "normal" entries into the Staff.Services attribute. Background is that I have 4 attributes that are associated with each other (Services, Services_Auto, Services_Del, and Services_Add). Services is calculated from the other three. Services_Auto is calculated from imports from other systems. Services_Add is used to add an additional attribute while Services_Del is used to remove an imported attribute. The rule for Services_Add is:

If Services was added to Staff.Services_Add
then insert AddedServices in Staff.Services
else if Services was removed from Staff.Services_Add
then remove RemovedServices from Staff.Services

Services_Del is the same. The problem is Services_Auto as it not only has to handle adds and deletes but it has to check to assure that it respects the overrides in Services_Add or Services_Del. I have tried:

If Services was added to Staff.Services_Auto and not (exists AddedServices where (AddedServices in Staff.Services_Del))
then insert AddedServices in Staff.Services
else if Services was removed from Staff.Services_Add and not (exists RemovedServices where (RemovedServices in Staff.Services_Add))
then remove RemovedServices from Staff.Services

and a process that tried to delete all Services in Services and then added back in the ones in Services_Auto and Services_Add and then deleted the ones in Services_Del

No luck.

Any ideas?
ckacoroski
Posts: 58
Joined: Mon Nov 13, 2006 9:15 pm
Location: Bothell, USA

Post by ckacoroski »

bummer, just figured out that the rule for Services_Add will not work as I have the case like so:

State1: Service1 defined in Services_Auto and Service2 in Services_Add
State2. Service2 added to Services_Auto
State3. Service2 removed from Services_Add

State3 breaks as the rule removes Service2 from Services when it should not.

Ugh!
ckacoroski
Posts: 58
Joined: Mon Nov 13, 2006 9:15 pm
Location: Bothell, USA

Post by ckacoroski »

Ok, I got this to work, but only by going back to the original rule set that triggers warnings like:

Value of Services could not be resolved
Unable to resolve facts for the following pattern IN expression for object staff.Services_Auto null

I think the error is coming from rules that look like this:

If Services was added to Staff.Services_Del and RemovedServices in Staff.Services_Auto
then remove AddedServices from Staff.Services

Where it tries to evaluate and RemovedServices... even though it hasn't evaluated the first part of the rule yet.

Everything seems to work perfectly, I just get the annoying warnings in the logs. Any ideas on a better way to solve this problem are appreciated.

cheers,

ski
Post Reply