If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#223 by Imad
Thu Jan 12, 2006 10:31 am
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

#224 by aware_support
Thu Jan 12, 2006 1:18 pm
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

#226 by Imad
Thu Jan 12, 2006 10:55 pm
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?

#228 by aware_support
Thu Jan 12, 2006 11:34 pm
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

#229 by Imad
Fri Jan 13, 2006 12:13 am
Thank you very much, it is working now.

Who is online

Users browsing this forum: No registered users and 15 guests