locked
How to determine event that cuased a plugin to fire... RRS feed

  • Question

  • I need to determine what event caused a plugin to fire.  I only want the code to execute for the case when the user clicks on the save or save&close.  I know I've sen a post somewhere on this topic but I just can't find it again.

    Code something like if "eventcode" = 1 or 2...

    Anybody know how to do this.

    Thanks, Lindsey


    LSM
    Saturday, October 22, 2011 11:54 PM

Answers

  • Actually it did not help, but that's probably my fault as I asked the question based on trying to find a post I remembered seeing.  So for the record, here's the issue I was trying to resolve...

    We have a plugin that fires on the Update event of an Opportunity.  This plugin references the OpportunityProduct (line items) of the opportunity and sums up a number of custom fields on that entity, placing the results on the opportunity itself.

    This plugin was failing during the transition from offline to online in the Outlook client.  What I was looking for, was a way to detect that the plugin was being fired for other than a Save or Save&Close event so that I could just return and avoid the error.

    It turns out that there is a property of the IExecutionContext called IsOfflinePlayback which returns true if the plugin fired due to the synchronization process.  By checking this in the plugin, i could simply return if true, and then everything was fine.

    Thanks for you reply.

    Lindsey


    LSM
    • Marked as answer by Lindsey Mundy Monday, October 31, 2011 11:35 PM
    Monday, October 31, 2011 11:35 PM

All replies

  • Hi Lindsay,

     

    You can identify the user action save or save and close using the event.Mode through scripting in the onsave event.

     

    if however you are looking for plugin events, they work based on crm messages like create, update etc. Through plugins you cannot identify user action difference between save or save and close. It could be trapped as either a create or update event on the record.

    HTH

    Sam


    Web: http://www.inogic.com
    Blog: http://inogic.blogspot.com
    Email: news@inogic.com
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Sam - Inogic Sunday, October 23, 2011 1:56 AM
    Sunday, October 23, 2011 1:56 AM
  • Hi Lindsay,

    Did this help?

    Please make sure to come back and mark the thread answered if it has resolved your query.

    Thanks!

    Sam


    Web: http://www.inogic.com
    Blog: http://inogic.blogspot.com
    Email: news@inogic.com
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Tuesday, October 25, 2011 4:34 AM
  • Actually it did not help, but that's probably my fault as I asked the question based on trying to find a post I remembered seeing.  So for the record, here's the issue I was trying to resolve...

    We have a plugin that fires on the Update event of an Opportunity.  This plugin references the OpportunityProduct (line items) of the opportunity and sums up a number of custom fields on that entity, placing the results on the opportunity itself.

    This plugin was failing during the transition from offline to online in the Outlook client.  What I was looking for, was a way to detect that the plugin was being fired for other than a Save or Save&Close event so that I could just return and avoid the error.

    It turns out that there is a property of the IExecutionContext called IsOfflinePlayback which returns true if the plugin fired due to the synchronization process.  By checking this in the plugin, i could simply return if true, and then everything was fine.

    Thanks for you reply.

    Lindsey


    LSM
    • Marked as answer by Lindsey Mundy Monday, October 31, 2011 11:35 PM
    Monday, October 31, 2011 11:35 PM