title: Microsoft Dynamics CRM 2013 SDK Issues - error
body: <p>I am having the following issue with Microsoft dynamics crm 2013:  </p>
  
  <p>I have two parent entities (legal contract or agreement) that reference amendments and financial details in a 1:M relationship.  I need to sum amounts on the child records and store that amount on the parent record.  </p>
  
  <p>I wrote a plugin that fires on create, update and delete for each of the child entities.  </p>
  
  <p>What has to happen is the following:</p>
  
  <ol>
  <li>Find out if my parent is a Legal Contract or an Agreement</li>
  <li>Sum all of the child record amounts</li>
  <li>Find the parent and store the summed values.</li>
  </ol>
  
  <p>Problems:
  Microsoft has removed the ability to get information from sub-grid components in the new SDK so even though the client has the data available, it is not accessible.</p>
  
  <p>When I run the below code I get an exception on the parentID that is null: the " If (c.Attributes.Contains(...) " test causes an exception.  </p>
  
  <p>If I run the same code as command line it works fine, it is only when running as a plugin that it pukes.</p>
  
  <p>Code snippet:</p>
  
  <pre><code>         EntityReference parentAgreementId = new EntityReference();
           EntityReference parentContractId = new EntityReference();
           QueryByAttribute querybyattribute = new QueryByAttribute("new_invoicedetails");
                   querybyattribute.ColumnSet = new ColumnSet(true);
  
                   //  Attribute to query.
  
                  querybyattribute.Attributes.AddRange("new_invoicedetailsid");
  
                   //  Value of queried attribute to return.
  
                  querybyattribute.Values.AddRange(sItem.getChildId());
  
                   //  Query passed to service proxy.
                   EntityCollection retrieved = service.RetrieveMultiple(querybyattribute);
  
                   //  Iterate through returned collection.
                   foreach (var c in retrieved.Entities)
                   {
                       If (c.Attributes.Contains("new_contractnumberid"))
                       {
                           parentContractId = c.GetAttributeValue&lt;EntityReference&gt;("new_contractnumberid");
                       }
  
                       If (c.Attributes.Contains("new_agreementnumberid"))
                       {
                           parentAgreementId = c.GetAttributeValue&lt;EntityReference&gt;("new_agreementnumberid");
                       }
  </code></pre>
  
  <p>Exception:</p>
  
  <p>
          -2147220891
          
              
              OperationStatus
              0
          
          
              SubErrorCode
              -2146233088
          
      
              An error occured in the plug-in.
      2014-02-24T20:27:31.028313Z
      
      </p>
  
  <pre><code>[Contracts.Plugins: Contracts.Plugins.Autonumber]
  [97f9577d-1394-e311-a461-000c29f9727b: PostInvoiceDetailsUpdate]
  Execption: Object reference not set to an instance of an object.    at Contracts.Plugins.SumAmounts.Execute(IServiceProvider serviceProvider)
  Execption: An error occured in the plug-in.    at Contracts.Plugins.SumAmounts.Execute(IServiceProvider serviceProvider)
  at Contracts.Plugins.Autonumber.Execute(IServiceProvider serviceProvider)
  </code></pre>
  
  <p>
  </p>