Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamics CRM 2011 how can I set the string field to be unique?

I want to add a field "Single Line of Text" to my custom entity which should be unique. How can I make Crm to throw me an exception when I try to create the duplicating value of the record?

like image 616
Nozim Avatar asked Feb 22 '23 15:02

Nozim


1 Answers

You have to create a plugin for this requirement which handles the Pre-Create/Pre-Update step for this entity. In this plugin you have to check whether the passed value is unique or not. If it's not, you throw an exception which cancels the operation and displays a dialog to the user (if the plugin runs synchronously).

throw new InvalidPluginExecutionException("Value passed for 'attribute' is not unique.");
like image 109
ccellar Avatar answered May 03 '23 03:05

ccellar