Posts

Showing posts from 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) ||               ...

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...

unit test for plugin

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Text; using Microsoft.Xrm.sdk; using System.ServiceModel; [TestClass] public class UnitTestPostOperation : UnitTestBase {     [TestMethod]     public void UnitTestMethod()     {         using (ShimsContext.Create())         {             string inData = "[{\"Key\":\"GuidId\",\"Value\":\"" + Guid.NewGuid().ToString() + "\"}]";             string inData = "{\"GuidId\",\"" + Guid.NewGuid().ToString() + "\"}]";             Entity target = new Entity("EntityName", Guid.NewGuid());             target["FieldName"] = new OptionSetValue(1);   ...