When will I register the crm 2011 online plugin for the pre-review phase?

I understand that a plugin registered for preliminary validation runs outside the database transaction, but I'm not sure I can think of a scenario when this would be preferable to a preliminary operation. Can someone give me an example of where pre-check registration might be useful?

+4
source share
2 answers

We have several plugins registered at the PreValidation event, although this is a package, not an online one.

I myself did not write these specific plugins, but I can describe them and justify using PreValidation rather than PreOperation.

Object: Account

Event: Delete

Logic: the plugin runs a preliminary check. Checks for contacts that link to any of the account addresses. If any of them are found, stop execution. If not, delete the account.

eg.

The Stackoverflow account has a Jeff Attwood House address and a glosrob contact. "glosrob" refers to "Jeff Attwood House" through customization. If the user chooses to delete "StackOverflow", we must find that "glosrob" refers to the address and prevents the removal.

The reason for this was that the developer discovered that at the PreOperation stage some aspects of the deletion had already occurred, namely, the cascade deletes. The logic of the plugin requires us to check all contacts - by registering with PreOperation, the contacts from the account have already been deleted, which makes the check obsolete.

In our previous scenario, when the user chose to delete the "StackOverflow" account, the "glosrob" "Contact" will be deleted before the plugin starts. Therefore, when the plugin was subsequently launched, it allowed removal.

As in most cases in CRM, it all comes down to requirements and solutions, but I think this gives you an idea of ​​why / when you can use the PreValidation phase. We have several others with similar reasoning that fire in the "Delete" event.

+13
source

I know his very old post, came here digging for the answer to the same question ... Later I found one key point from MSDN on the same topic, and I thought it would be useful if I published information for everyone here .

The Prevalidation plugin will happen before security checks. For example: if the account is a “VIP” account and you do not want this account to be deleted (regardless of whether it is superuser / administrator), this can happen better in a preliminary check. Since at that time you really did not bother who the user was and what his permissions were (even he may not have any rights to delete any entries in the system), CRM will go and check the database for user security roles during the preliminary operation , and that is where the first hit of the database will happen. Before that, he himself, we can stop the development of the plugin based on our validation rules.

I hope this makes sense ...

thanks

Relations Srikanth

+2
source

Source: https://habr.com/ru/post/1384029/


All Articles