Vtiger duplicates prevention. Change condition from AND to OR

Vtiger duplicates prevention. Change condition from AND to OR

Vtiger 7.3 has one great feature - checking records for duplicates before saving or changing. It works as follows - you go to the module settings (field management), in it you will have access to the "Duplicate Management" or Duplicate Prevention tab. When you go to this tab, you can specify the fields that you will check before saving.

On the screenshot in our example, we check new contacts for duplicates in two fields - Organization name and phone number. And the system works as follows - as soon as we try to create a new contact with the same organization and phone number, the system will not allow us to do this. Those. in this case, the AND condition works. The contact must be with the same organization AND phone number.

But what if we want to use the OR condition? Those. we want, for example, to check contacts for uniqueness by email or phone number. In other words, we want to achieve this behavior when the system checks for a match email, then the phone number, and if something of them is found, the system prohibits saving the record.

Fortunately, this is very easy to do. To do this, go to the file:

modules / Vtiger / handlers / CheckDuplicateHandler.php

We find a line around 165 (your number may be different), which looks like this:

$ conditionsSql = implode ("AND", $ conditions);

We delete it, insert the following text instead:

$ conditionsSql = implode ("OR", $ conditions);

Those, we changed only one word in it, and replaced AND with OR.

We save the file and now we can search for duplicates by OR condition.

Popular Posts

My most popular posts

Maximum productivity on remote job
Business

Maximum productivity on remote job

I started my own business and intentionally did my best to work from anywhere in the world. Sometimes I sit with my office with a large 27-inch monitor in my apartment in Cheboksary. Sometimes I’m in the office or in some cafe in another city.

Hello! I am Sergey Emelyanov and I am hardworker
Business PHP

Hello! I am Sergey Emelyanov and I am hardworker

I am a programmer. I am an entrepreneur in my heart. I started making money from the age of 11, in the harsh 90s, handing over glassware to a local store and exchanging it for sweets. I earned so much that was enough for various snacks.

Hire Professional CRM developer for $25 per hour

I will make time for your project. Knowledge of Vtiger CRM, SuiteCRM, Laravel, and Vue.js. I offer cooperation options that will help you take advantage of external experience, optimize costs and reduce risks. Full transparency of all stages of work and accounting for time costs. Pay only development working hours after accepting the task. Accept PayPal and Payoneer payment systems. How to hire professional developer? Just fill in the form

Telegram
@sergeyem
Telephone
+4915211100235