Rule that compare form attributes values with exist database

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Imad
Posts: 28
Joined: Tue Jan 03, 2006 3:36 pm

Rule that compare form attributes values with exist database

Post by Imad »

Dear Support Team,

I have a student object that has compulsory attributes as following
Student(FirstName,LastName,DOB)

I would like to create a rule that prevent me from creating a new instance that has the same attributes values on my database. When I want to create a student with the above attributes and click on the create button the rule should check my previous created student’s data and returns error message if the same values found in the database in order to prevent the duplication for my student’s data.

Please help of how the rule should be in order to compare the new values on the form with database values for those attributes?

Many thanks

Imad
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Dear Imad,

your rule should look something like this:

If Student IS NEW AND EXISTS Student WHERE (Student.FirstName = ThisStudent.FirstName AND Student.LastName = ThisStudent.LastName) Then REPORT ERROR 'Student with these first and last names already exists'

You can drop the first condition (IS NEW) - in this case the rule will be checked even when student's values are changed.

Best Regards
Aware IM Support Team
Imad
Posts: 28
Joined: Tue Jan 03, 2006 3:36 pm

Post by Imad »

I have created this rule as you described but when I want to create a student(in testing database) the error message appears even my database is empty and no student’s data yet in it. What is wrong in the rule, please help?
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Sorry, forgot a very important condition that checks that the student is not the student that has been just created (Student.ID <> ThisStudent.ID). The rule should be:

If Student IS NEW AND EXISTS Student WHERE (Student.ID <> ThisStudent.ID AND Student.FirstName = ThisStudent.FirstName AND Student.LastName = ThisStudent.LastName) Then REPORT ERROR 'Student with these first and last names already exists'

Hope this helps
Aware IM Support Team
Imad
Posts: 28
Joined: Tue Jan 03, 2006 3:36 pm

Post by Imad »

Thank you very much, it is working now.
Post Reply