web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin is firing twice, how to stop it?

(0) ShareShare
ReportReport
Posted on by 230

Hi,

I am implementing Audit in MS CRM 4.0. Whenever user views record for entites like Account, Contact,Opportunity and etc, I am capturing accessed users information & storing it in Audit custom entity.

I have achived this using plugin. I have registered plugin for the above entites for message "Retrieve", stage ->PostState, Pipeline ->parentpipeline, Asynchronous.

It is working fine for opening existing records. But when I create new record for the above entities (onclick of save)  the plugin is firing twice and result it is creating duplicate records in the Audit entity.

For save & close, it is firing once and the record is captured in audit entity.

Please advice me. 

Regards,

Prabhu

 

*This post is locked for comments

I have the same question (0)
  • ErhanAkova Profile Picture
    255 on at

    You may need to check the Stage Numbers within your code.You need to execute your code for AfterMainOperation.

    Erhan Akova

    http://www.isvlabs.com

     

  • Prabhu Selvam Profile Picture
    230 on at

    Hi Erhan,

    Thanks for your quick reply. We tried with stage number but no luck. Every time the stage number is same. For PostRetrieve the stage number is 40. Please let me know if you any idea.

    Regards,

    Prabhu

  • Srinath Goniguntala Profile Picture
    20 on at

    Hi Prabhu

    I know I am responding too late, but still this may help someone.

    When you import the Plugin from export solution xml file, it will create duplicate steps on existing plugins --> this leads to plugin firing twice or more. Delete the duplicate steps on the Plugin. That should resolve the issue. Thanks

    Regards

    Srinaath

  • Community Member Profile Picture
    on at

    hi the difference between the save and save & Close button is "Save" button updates records and loads the page again. so you catch the same record twice. May be you can omit the second audit record by checkinng time if the two audit records' time is near omit the second..

  • Tejas Profile Picture
    15 on at

    Hi Shiva,

    I have a Pre-operation plugin on appointment getting called twice. i checked there is no duplicate steps in solution and in plugin registration tool.

    Please suggest.

    Tejas

  • Suggested answer
    tiagolvsantos Profile Picture
    740 on at

    Place this in your code:

    if (context.Depth > 1)

                       return;

    Give it a try.

    gl

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans