Compare new record to existing record

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
lueu
Posts: 89
Joined: Tue Mar 07, 2023 11:49 pm

Compare new record to existing record

Post by lueu »

Hope someone can helt with this. How can I make a rule to compare a new record beeing entered to an already existing record?
I've tried IF EXISTS .... WHERE (comparing some fields) THEN REPORT ERROR 'Duplicate row'
But there is no error thrown, so I'm obviously not catching duplicate values even though I enter the same value as the existing one for the fields I am trying to compare.. Maybe IF EXISTS is wrong? Any tips on what I can try instead?
customaware
Posts: 2397
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Compare new record to existing record

Post by customaware »

Have a look at the Customer BO in the CRM Sample App....

In the Business Object Rules you will see this....

If EXISTS SystemUser WHERE (SystemUser.LoginName=ThisCustomer.LoginName AND SystemUser.ID<>ThisCustomer.ID) Then REPORT ERROR 'User with this login name already exists. Please choose a different name'

Notice it is checking the ID
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
lueu
Posts: 89
Joined: Tue Mar 07, 2023 11:49 pm

Re: Compare new record to existing record

Post by lueu »

Thanks! May I ask what This points to? Is it what the user is entering or the existing record? This/that confuses me :oops:

Also, to clearify: I want to allow the user to make a new row based on an existing row (use process for that), but do not want them to make a new row exactly like an existing. Everything (name, id and so forth) but the times (like monday from - to) and valid period should be the same. If there is already a schedual with from monday 08.00 til monday 20.00 within the same periode, I wan't to throw an error.
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Compare new record to existing record

Post by aware_support »

"This" is to distinguish existing customers from the current customer being added to the system.
Aware IM Support Team
Post Reply