Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Stop record creation from Pre-validate Plugin without throwing exception

(0) ShareShare
ReportReport
Posted on by 90

Hello Techies, 

I have a pre-validate plugin for duplicate detection.

based on the criterion if there is duplicate records found, I want to stop the record creation without throwing the Invalid Plugin Execution Exception.

Thanks in Advance. 

Viswa

*This post is locked for comments

  • Suggested answer
    Seamus Profile Picture
    1,577 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Hello,

    Long time ago.....I have the same requirement myself - I don't know if you got a better solution (let me know, please, if you did) - my workaround was to write a value "DUPE" to a custom field on prevalidation then have an oncreate workflow to check the value of the custom field - if it is "DUPE" then deactivate the record immediately.

    Best wishes,

    - Seamus

  • Viswanath Profile Picture
    90 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    This is the first thing that I have tried before posting question, it didnt work.

  • Rawish Kumar Profile Picture
    13,758 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Hi There,

    Can't you simply use "return;"?

    as in :

    if( records matched)

    return;

    not sure how your code is structured, but try this.

  • Viswanath Profile Picture
    90 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Hello Anand,

    looks like that is the only alternate and no other feasibility from code side.

    Thanks,

    Viswa

  • crm development Profile Picture
    870 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Hi Viswanath,

    You have to throw Invalid Plugin Execution Exception to revert record creation in crm. This is how Plugin pipeline works.

    Would it be possible to validate create/update record in external system itself.

    Thanks,

    Anand

  • Viswanath Profile Picture
    90 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Hello Temmy,

    Just tried

    record still getting created.

  • Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    If you don't want to get error stopper. Actually the easiest way is doing this one:

    try{

    service.Create(entity);

    }

    catch(Exception ex){

    //Surpress the error weather got problem or not

    }

  • Viswanath Profile Picture
    90 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Any other approach like Abort() in C# threading ? 

  • Viswanath Profile Picture
    90 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    Hello Adrian,

    I have written some duplicate detection code and if I found records I want to stop execution without throwing exception, which mean record shouldnt get created.

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,914 on at
    RE: Stop record creation from Pre-validate Plugin without throwing exception

    If you are from external exe, actually you can wrap the code using block try and catch to surpress the error if you've got error unique right? It should be got error if you still want to have unique data insert into your system and not creating the error. It means that your code works normally.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans