Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

prevalidation or preoperation

Posted on by 524

Hi,

I am writing a plugin for creating an account and check whether the account name already exists or not. if already exists, then we should not allow to create the account. My question is in plugin registration, which event pipeline we have to chose, prevalidation or preoperation ?

*This post is locked for comments

  • Suggested answer
    Michel Gueli Profile Picture
    Michel Gueli 982 on at
    RE: prevalidation or preoperation

    I'm not really convinced by the answers. Andrew has a good point.

    What the plugin needs to do is to check if the action is valid. Does the name already exists? If it exists, the action is not valid. The action can be done in the pre-validation. This is the most lightweight solution. There is no need to execute this logic within the database transaction. What is the benefit for this example? It is just a check.  

    If the action is valid (name is empty) and the process will continue, then all the normal validation, security checks will be done. I don't see any problems with that.

  • Nitin Meria Profile Picture
    Nitin Meria 216 on at
    RE: prevalidation or preoperation

    +1

  • Temmy Wahyu Raharjo Profile Picture
    Temmy Wahyu Raharjo 2,914 on at
    RE: prevalidation or preoperation

    Hi. PreValidation on Msdn is not guarantee in transaction. So I'd prefer doing on PreOperation.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: prevalidation or preoperation

    Hi Anand,

    In addition Andrew answer ,

    Few things need to be considered .

    As per MSDN the pre-validation stage occurs prior to security checks being performed to verify the calling or logged on user has correct permission to performed the intended operation.

    Secondly pre-validation occurs outside database transactions.

    Based on above two main criteria,, I would recommend to do this type of validation in the Pre-operation event  instead of pre-validation. As because creation of account should be require the security check .

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: prevalidation or preoperation

    Hello,

    You can use any of but it is safer to use PreOperation. In situation when Account is created from Lead during qualification PreValidation plugins are not triggered.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans