title: How to prevent firing Dynamics CRM Plugin execution while updating an entity using web service?
body: <p>I have implemented a plugin for my Dynamics CRM which is firing on Update message for incident entity.
  Also I have a web service for external users which can update just two attributes of incident entity from outside.  </p>
  
  <p>The problem is while external users use the web service to update entity, the plugin will fire also.
  I want to bind the plugin going to be fired just inside CRM when incident entity changed and prevent it firing by outside requests.</p>
  
  <p>I checked below conditions in my plugin for preventing infinite loop and it works but not works for preventing firing by outside update requests.</p>
  
  <pre><code>    if (context.Depth &gt; 1 || 
          context.Mode != 1 || 
          context.MessageName != "Update" || 
          context.IsolationMode != 1)
      {
          return;
      }
  </code></pre>
  
  <p>To register plugin I've used the Plugin Registration Tool and I have set the step message to Update, and Run in User's Context as Calling User.</p>
  
  <blockquote>
    <p><a href="https://i.stack.imgur.com/DJbZu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DJbZu.jpg" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>In my web service I've used <code>Xrm.Sdk</code> and <code>Xrm.Sdk.Client</code> to connect to CRM and update entity directly.</p>
  
  <pre><code>        ColumnSet cs = new ColumnSet(new string[] {
                  "description", "statuscode"
              });            
          Guid recordId = new Guid(caseID);            
          Entity currentRecord = crmService.Retrieve("incident", recordId, cs);
          OptionSetValue osv = new OptionSetValue(1);
          currentRecord["statuscode"] = osv;
          currentRecord["new_answers"] = answer;
          currentRecord["new_lastanswerdate"] = currentDate;
          crmService.Update(currentRecord);
  </code></pre>
  
  <p>Anyone has any idea - How can I prevent plugin firing while an entity updated from outside of CRM?</p>