Duplicates

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Rebecca
Posts: 21
Joined: Fri May 27, 2005 12:46 am

Duplicates

Post by Rebecca »

I am having trouble with a rule to prevent duplicate attribute values. I have entered a rule saying :-
If EXISTS [BusinessObject] WHERE [BusinessObject.Attribute=ThisBusinessObject.Attribute] Then REPORT ERROR 'BusinessObject with this Attribute already exists. This system does not allow duplicates'
When this rule is not there, I can enter new values for this attribute. Once I have entered this rule, I cannot enter ANY new values, whether they are duplicates or not. Am I entering this rule incorrectly?
I have used this rule within other Business Objects with no problems.
aware_support2
Posts: 595
Joined: Sun Apr 24, 2005 2:22 am
Contact:

Post by aware_support2 »

Rebecca,

> Once I have entered this rule, I cannot enter ANY new values, whether they are duplicates or not.
This happens because the object finds itself. You need to add another condition to check that the existing object is not the object being edited/created. The easiest way is to compare the object IDs. For example, here is the 'Uniqueness of login name' rule the system automatically adds to members of group SystemUser, which you can find on object RegularUser in your configuration:

If EXISTS SystemUser WHERE (SystemUser.LoginName = ThisRegularUser.LoginName AND SystemUser.ID <> ThisRegularUser.ID) Then
REPORT ERROR 'User with this login name already exists. Please choose a different name'
Aware IM Support Team
Rebecca
Posts: 21
Joined: Fri May 27, 2005 12:46 am

Post by Rebecca »

Great thanks. Did this and now it works fine.
Post Reply