In our unit tests we discovered the behavior that inserted records are not immediately retrievable.
This smal code leads to the following output:
class Program { static void Main(string[] args) { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; var service = new CrmServiceClient(ConfigurationManager.ConnectionStrings["MyCRMServer"].ConnectionString); Account test = new Account { Name = "Test", new_tagEnum = new[] { new_account_new_Tag.Black, new_account_new_Tag.Blue } }; service.Create(test); var start = DateTime.Now; var count = 0; EntityCollection result = new EntityCollection(); while (result.Entities.Count == 0) { count++; result = service.RetrieveMultiple(new FetchExpression(GetFetch(new_account_new_Tag.Black))); } var end = DateTime.Now; Console.WriteLine(count); Console.WriteLine(end - start); Console.ReadLine(); } public static string GetFetch(new_account_new_Tag param) { string fetch = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='account'> <attribute name='name' /> <attribute name='primarycontactid' /> <attribute name='telephone1' /> <attribute name='accountid' /> <order attribute='name' descending='false' /> <filter type='and'> <condition attribute='new_tag' operator='contain-values'> <value>{(int)param}</value> </condition> </filter> </entity> </fetch>"; return fetch; } }
That brings me to the following conclusion:
- the transaction is not finished after a successful insert.
- Up to 3 seconds elapse before the data record can be read correctly.
I executed the same code again, but with a query for the name. The result was as expected, the record was delivered immediately.
This means that only the multiselect options are normalized asynchronously.
*This post is locked for comments