I've set a rule:
IF EXISTS MYOBJ WHERE (MYOBJ.ID = THISMYOBJ.ID) THEN REPORT ERROR 'DUPLICATE ID DETECTED'
When creating a new object this reports the error every time regardless of the ID entered.
Is there another way? The ID attribute is indexed.
Thanks
Preventing Duplicate ID
Hi,
Your rule will only find itself, not duplicates. You need to exclude the current object, not limit your EXIST statement specifically to the current object. If you study the rule that is loaded by default in every business space, you will see what you need to do:
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'
cheers,
Pete
Your rule will only find itself, not duplicates. You need to exclude the current object, not limit your EXIST statement specifically to the current object. If you study the rule that is loaded by default in every business space, you will see what you need to do:
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'
cheers,
Pete
I think I spoke too soon. I don't quite follow how to exclude the current object in this situation.
MEMBERS
Members.ID (text alphanumeric 8 characters)
Members.Name
Members.Address
Members.Phone
etc.
Any number of regular users can create new MEMBERS and I need to prevent the entry of duplicate Members.ID. I don't want Members.ID to be changed and create a duplicate either. Names can and will be duplicated i.e. "Smith, John".
Hope you can clear this up for me.
Thanks again
MEMBERS
Members.ID (text alphanumeric 8 characters)
Members.Name
Members.Address
Members.Phone
etc.
Any number of regular users can create new MEMBERS and I need to prevent the entry of duplicate Members.ID. I don't want Members.ID to be changed and create a duplicate either. Names can and will be duplicated i.e. "Smith, John".
Hope you can clear this up for me.
Thanks again
I'm confused about your use of the attribute ID.
I thought that ID was reserved for AwareIM use. You won't see it in the list of attributes in a BO, but you will see if listed if you create a Query of the BO.
Are you talking about trying to control this ID or some other ID?
I thought that ID was reserved for AwareIM use. You won't see it in the list of attributes in a BO, but you will see if listed if you create a Query of the BO.
Are you talking about trying to control this ID or some other ID?
Tom - V8.8 build 3137 - MySql / PostGres
oops -- too many ID type attributes floating around. My bad.
This WILL work:
If EXISTS Members WHERE (Members.IDCode=ThisMembers.IDCode AND Members.ID<>ThisMembers.ID)
Then
REPORT ERROR 'Member with this ID Code already exists. Please choose a different ID Code'
This WILL work:
If EXISTS Members WHERE (Members.IDCode=ThisMembers.IDCode AND Members.ID<>ThisMembers.ID)
Then
REPORT ERROR 'Member with this ID Code already exists. Please choose a different ID Code'
Tom - V8.8 build 3137 - MySql / PostGres