How to check duplicate record before saving new record in custom module

Hello Everyone,

how can i prevent to enter duplicate record according to a custom field in a custom module. that when user click on save button then message will come that record is already available. Please suggest me.

Thanks

there’s no easy way to do this, only for import, if you want to achieve this you’ll need to take a look at the code in modules/Accounts/ShowDuplicates.php and ShowDuplicates.tpl

best regards