Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans