Skip to main content

Posts

Showing posts from December, 2018

Prevent NULL inserts during updates

Recently, I had an issue that I needed to overcome.  The problem was that the Dynamics 365 instance I was working on, was integrated with multiple other systems with some long running external processes and possible old data in the UI when a record is open, overriding what the value was set to from the external processes.  What was happening is that on create of a contact, we can have a NULL e-mail.  This is normal behavior.  Our external process would be running and update the NULL e-mail field while the record was open in the UI.  Because the UI hadn't been refreshed and the user made other changes, the e-mail would be blanked out (NULL).  To make sure that the field once populated (yes, this is a business requirement) could not be cleared, I wrote a small pre-operation plugin that does the following:

Check's the plugin context to see if we are trying to update the emailaddress1 or emailaddress2.  If we are trying to update either email address.  Than we check to see if conte…