title: Show message only once
body: <p>I am building a customized add in for our CRM system. When end users meet certain  conditions, I would like to only pop up a message box once. I am not sure whether I do correctly in the follow implementation: </p>
  
  <p>I declare a trigger variables in global scope: </p>
  
  <pre><code>public class MyWorkspaceAddIn : Panel, IWorkspaceComponent2
      {
  
          private bool _readOnly;
          private IRecordContext _recordContext;
          private IGlobalContext _globalContext;
          private bool _triggerPopup = true;
  </code></pre>
  
  <p>The pop up code in the following class: </p>
  
  <pre><code> void _incident_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
          {//check property and/or i.Prod and then show the popup
  
             // MessageBox.Show(e.PropertyName); //Check what property name is
  
              if (_incident.ProductID == 182 &amp;&amp; _triggerPopup) //If product ID is 183 in incident 
              {
                  MessageBox.Show("The GO Classic will soon be end of life, make sure you propose the customer to buy a new device and offer maximum 20% discount to reward his/her loyalty (NOTE: refurbished devices are not included in this offer).");
                  _triggerPopup = false; //Do not pop up
              }
  </code></pre>
  
  <p>I hope the message box will only pop up once.</p>
  
  <p>Full code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.AddIn;
  using RightNow.AddIns.AddInViews;
  using RightNow.AddIns.Common;
  using System.Windows.Forms;
  
  ////////////////////////////////////////////////////////////////////////////////
  //
  // File: MyWorkspaceAddIn.cs
  //
  // Comments:
  //
  // Notes: 
  //
  // Pre-Conditions: 
  //
  ////////////////////////////////////////////////////////////////////////////////
  namespace TriggerAddIn
  {
      [AddIn("My VAS AddIn", Version = "1.1.0.2")]
      public class MyWorkspaceAddIn : Panel, IWorkspaceComponent2
      {
  
          private bool _readOnly;
          private IRecordContext _recordContext;
          private IGlobalContext _globalContext;
          private bool _triggerPopup = true;
  
          IIncident _incident; //Define IIncident outside dataLoaded event; 
          //Get reference when the incident open in workspace.
          public MyWorkspaceAddIn(bool inDesignMode, IRecordContext recContext, IGlobalContext globalContext)
          {
              /*MessageBox.Show("AddIns Load My workspace plugin");*/
  
              _recordContext = recContext;
              _globalContext = globalContext;
              //Check wheather users 
              if (!inDesignMode &amp;&amp;_recordContext != null)
              {   //Add our custom event
                  _recordContext.DataLoaded += new EventHandler(_recordContext_DataLoaded);
              }
          }
          //Custom Event handler
          void _recordContext_DataLoaded(object sender, EventArgs e)
          {
              _incident = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident;
  
              if (_incident != null)
              {
                  _incident.PropertyChanged -= _incident_PropertyChanged;
                  _incident.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_incident_PropertyChanged);
              }
          }
          void _incident_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
          {//check property and/or i.Prod and then show the popup
  
             // MessageBox.Show(e.PropertyName); //Check what property name is
  
              if (_incident.ProductID == 182 &amp;&amp; _triggerPopup) //If product ID is 183 in incident 
              {
                  MessageBox.Show("The GO Classic will soon be end of life, make sure you propose the customer to buy a new device and offer maximum 20% discount to reward his/her loyalty (NOTE: refurbished devices are not included in this offer).");
                  _triggerPopup = false; //Do not pop up
              }
              /*
              if (_incident.CategoryID == 2353)
              {
                  Form1 myForm = new Form1();
                  myForm.ShowDialog();
              }*/
          }
          #region IAddInControl Members
  
          public Control GetControl()
          {
              return this;
          }
  
          #endregion
  
          #region IWorkspaceComponent2 Members
  
          public bool ReadOnly
          {
              get
              {
                  return _readOnly;
              }
              set
              {
                  _readOnly = value;
              }
          }
  
          public void RuleActionInvoked(string actionName)
          {
  
          }
  
          public string RuleConditionInvoked(string conditionName)
          {
              return "";
          }
  
          #endregion
      }
  
      [AddIn("My VAS Factory AddIn", Version = "1.1.0.2")]
      public class MyWorkspaceAddInFactory : IWorkspaceComponentFactory2
      {
  
          private IGlobalContext _globalContext;
  
          #region IWorkspaceComponentFactory2 Members
  
          IWorkspaceComponent2 IWorkspaceComponentFactory2.CreateControl(bool inDesignMode, IRecordContext context)
          {
              return new MyWorkspaceAddIn(inDesignMode, context, _globalContext);
          }
  
          #endregion
  
          #region IFactoryBase Members
  
          public System.Drawing.Image Image16
          {
              get { return Properties.Resources.AddIn16; }
          }
  
          public string Text
          {
              get { return "Trigger add in for VAS"; }
          }
  
          public string Tooltip
          {
              get { return "Trigger add in for VAS Tooltip"; }
          }
  
          #endregion
  
          #region IAddInBase Members
  
          public bool Initialize(IGlobalContext context)
          {
              _globalContext = context;
  
              return true;
          }
  
          #endregion
  
      }
  }
  </code></pre>