Sunday, 1 September 2013

Get Post Follow Id Plugin Code mcrm 2011




      private void GetPostfollowId(IOrganizationService service,Entity postImage,bool EntiytRelated)
      {
              if  ( EntityRelated == true)
           {
               QueryExpression qep = new QueryExpression();
               qep.EntityName = "postfollow";
               qep.ColumnSet = new ColumnSet();
               qep.ColumnSet.Columns.Add("postfollowid");
               ConditionExpression conExp = new ConditionExpression();
               conExp.AttributeName = "regardingobjectid";
               conExp.Operator = ConditionOperator.Equal;
               conExp.Values.Add(postImage.Id);
               FilterExpression fep = new FilterExpression();
               fep.Conditions.Add(conExp);
               qep.Criteria.AddFilter(fep);
               EntityCollection entityCollection = service.RetrieveMultiple(qep);
               foreach (Entity postfollow in entityCollection.Entities)
               {
                   Guid postFollowId = (Guid)postfollow["postfollowid"];
                   service.Delete("postfollow", postFollowId);
                           
               }
            }
        }
    }
}

No comments:

Post a Comment