Hi, i am using ParentId to retrieve only the records of the current account of a customer address in a plugin,
it worked fine when the plugin was triggered on the create of a customer address, but when i tried it in update i get the error :
Error of Plugin: System.NullReferenceException: Object reference not set to an instance of an object. can anyone help ?
var addresstype = entity.GetAttributeValue("addresstypecode").Value;
tracingService.Trace("Addresstype value = " addresstype);
var accountid = entity.GetAttributeValue("parentid").Id;
tracingService.Trace("ACcount value = " accountid);
QueryExpression query = new QueryExpression("customeraddress");
query.ColumnSet = new ColumnSet("addresstypecode");
query.Criteria.FilterOperator = LogicalOperator.And;
query.Criteria.AddCondition("addresstypecode", ConditionOperator.Equal, addresstype);
query.Criteria.AddCondition("parentid", ConditionOperator.Equal, accountid);
EntityCollection collection = service.RetrieveMultiple(query);