Posts

Showing posts from September, 2019

Attribute Value Changed and Get and Set value of the Attribute value with C#

     public static bool IsOptionSetChanged(string field, Entity target, Entity preImage)         {             if (target == null)             {                 throw new ArgumentNullException(nameof(target));             }             bool result = false;             if (target.Contains(field))             {                 int? targetValue = CommonHelper.GetOptionSetValue(field, target);                 int? preImageValue = CommonHelper.GetOptionSetValue(field, preImage);                 if (!((targetValue == null && preImageValue == null) ||                       (targetValue != null && preImageValue != null && targetValue.Value ==                                                 preImageValue.Value)))                 {                     result = true;                 }             }             return result;         } -----------------------------------------------------------------------------------------------------------------

Retrieve More than 5000 records using Fetchxml with C#

 EntityCollection result = new EntityCollection();             result.Entities.AddRange(RetrieveAllRecords(orgService, crtypFecthcXml));    public static List<Entity> RetrieveAllRecords(IOrganizationService orgService, string fetchXml)         {             fetchXml = fetchXml.Replace("<fetch ", "<fetch {0} ");             var moreRecords = false;             int page = 1;             var cookie = string.Empty;             List<Entity> entities = new List<Entity>();             do             {                 var xml = string.Format(CultureInfo.InvariantCulture, fetchXml, cookie);                 var collection = orgService.RetrieveMultiple(new FetchExpression(xml));                 if (collection.Entities.Count > 0)                 {                     entities.AddRange(collection.Entities);                 }                 moreRecords = collection.MoreRecords;                 if (moreRecords)                 {