web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
New Discussion

Inserting records with MultiSelect option records has asynchronous behavior.

(1) ShareShare
ReportReport
Posted on by

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;
        }
    }


37048.Capture.JPG

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans