Phidiax Tech Blog

Adventures in custom software and technology implementation.

BizTalk error during dynamic creation of SharePoint folders under high load. "Your changes conflict with those made concurrently by another user"

Recently I wrote a C# helper class to dynamically create a folder in SharePoint. This library is being used within a BizTalk orchestration while posting documents. The workflow has the following main purpose:

  1. Dynamically create the target SharePoint folder in SharePoint 2013
  2. Upload media to the target SharePoint folder

During load conditions, the helper class sometimes throws the exception error below:

CreateDocumentFolder Exception: Save Conflict.

Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.

Apparently, SharePoint manages folder creation requests sluggishly. Nevertheless, without the proper folder created in SharePoint, the BizTalk orchestration will not be able to upload media.

You can easily resolve the issue by injecting retry logic via Enterprise Library 5.0 Fault Handling Application Block. You can create intricate retry policies to manage exception scenarios.

In a more simple approach, a while loop will do, as seen below:

public static void CreateContactDocumentFolder(string siteURL, string firstName, string lastName, string contactGuid)
            Int16 intRetried = 0;
            Boolean blnCompleted = false;

            while (blnCompleted == false)
                    Microsoft.SharePoint.Client.ClientContext context = new Microsoft.SharePoint.Client.ClientContext(siteURL);
                    Microsoft.SharePoint.Client.List lists = context.Web.Lists.GetByTitle("Contact");


                    lists.EnableFolderCreation = true;

                    //Create dynamic subfolder under "Contact" folder in SharePoint
                    lists.RootFolder.Folders.Add("Contact/" + firstName + " " + lastName + "_" + contactGuid);

                    blnCompleted = true;
                catch (Exception ex)
                    //retry 100 times

                    if (intRetried == 100)
                        blnCompleted = true;  // exit loop
                        // Write error to log

Privacy Policy  |  Contact  |  Careers

2009-2017 Phidiax, LLC - All Rights Reserved