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.
Duplicates
-
- Posts: 595
- Joined: Sun Apr 24, 2005 2:22 am
- Contact:
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'
> 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