Показать сообщение отдельно
Старый 09.09.2021, 16:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
crmtipoftheday: Tip #1414: Enforce unique email but ignore inactive records
Источник: https://crmtipoftheday.com/1414/enfo...inactive-users
==============

Alternate keys are great way to enforce uniqueness of the column values. For example, if you want lead emails to be truly unique, just add an alternate key and no user will be able to bypass that (unlike the duplicate detection which is a fairly timid mechanism). The challenge is when you want that uniqueness to apply only to active records. Bear with me.

You thought that lead was lost forever and deactivated the record (you do not ever delete important records, right?). Now they are coming back, rejuvenated and refreshed and ready to buy not one but seven of your wonderful Jigamagigs. New lead is created but with the same email and that’s OK – we don’t hold grudges. What you don’t want is two active leads with the identical emails.

Alternate key using email are not going to work for you in this scenario, but you can enforce the uniqueness using a faux column that contains email for active records and null for inactive.
It works because alternate keys ignore null values.

The walkthrough below uses the contact table.

<ol>Create a column large enough to hold email addresses. No need to make it searchable or enable audit.
Create new real-time workflow (and you can do that from the new solution explorer)
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.