Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:23:56+00:00 2026-06-14T14:23:56+00:00

I am experiencing difficulty creating a file in a document library using the client

  • 0

I am experiencing difficulty creating a file in a document library using the client object model. My custom Visual Studio 2010 workflow is not detecting the updates I am making to the file’s list item after it is created.

I’d like to give an idea of the infrastructure to answer some likely questions:

  • The document is uploaded to a web service, which is responsible for actually inserting the document in the library and configuring the values of its list columns
  • The web service is performing this operation using the Client Object Model
  • The web service is authenticating against the SharePoint site with an account created for business intelligence automation that DOES NOT RUN as the system account when interacting with SharePoint; it is, however, a member of SharePoint owners
  • The operations in the custom workflow depend on the file’s list item columns being populated before it can proceed to assign tasks to the users in two of those columns; for that reason, I created a While activity to monitor changes in the list item until those two columns are no longer null

The following is a sample of what the web service is doing. It is running in IIS under the Business Intelligence user identity. I’ve added some comments as to which operations I was anticipating the workflow would respond appropriately.

Using client As New ClientContext(My.Settings.SharePointSiteURL)

    // Pre-processing to determine appropriate user ID values for columns

    Dim fci As New FileCreationInformation() With {
        .Content = IO.File.ReadAllBytes(storagePath),
        .Overwrite = True,
        .Url = String.Format("{0}/{1}", theList.RootFolder.ServerRelativeUrl, theFileName)
    }

    Dim theFile As Microsoft.SharePoint.Client.File = theList.RootFolder.Files.Add(fci)

    // Expecting the workflow to be activated here
    client.ExecuteQuery()

    theFile.ListItemAllFields("Project_x0020_Manager") = pmId
    theFile.ListItemAllFields("Project_x0020_Accountant") = paId
    theFile.ListItemAllFields.Update()

    // Expecting the onWorkflowItemChanged activity to be invoked here
    client.ExecuteQuery()
End Using

The workflow does activate when a file is uploaded and continues on to wait for a change event from SharePoint, but that event never arrives as a direct result of the web service’s operations. I’m able to modify the item manually and successfully continue on.

Is there a consideration when using the Client Object Model that might preclude these events from firing normally?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:23:57+00:00Added an answer on June 14, 2026 at 2:23 pm

    Seems like some weird race condition. I was able to partially reproduce your problem with some sample code:

    using (var client = new ClientContext(ConfigurationManager.AppSettings["Site"]))
    {
        client.Load(client.Site);
        client.Load(client.Site.RootWeb);
        var list = client.Site.RootWeb.Lists.GetByTitle("Shared Documents");
        client.Load(list);
        client.Load(list.RootFolder);
        client.ExecuteQuery();
        var fci = new FileCreationInformation()
                  {
                      Content = File.ReadAllBytes(ConfigurationManager.AppSettings["File"]),
                      Overwrite = true,
                      Url = list.RootFolder.ServerRelativeUrl + "/" + "file.xml"
                   };
        var file = list.RootFolder.Files.Add(fci);
        client.ExecuteQuery();
    
        //If following 3 lines are commented out, problem you described may or may not occur. I wasn't able to run into problems, when i loaded file and list item before.
        //client.Load(file);
        //client.Load(file.ListItemAllFields);
        //client.ExecuteQuery();
    
        //Problem also doesn't occur, when i put here
        //System.Threading.Thread.Sleep(1000); 
    
        //If code just runs here without delay, sometimes i run into issue you described. 
        var itm = file.ListItemAllFields;
        itm["SampleColumn"] = "Test content!";
        itm.Update();
        client.ExecuteQuery();
    }
    

    and workflow:

    public Workflow1()
    {
        InitializeComponent();
    }
    
    public Guid workflowId = default(System.Guid);
    public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
    
    private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
    {
        var comment = "Workflow started!, item SampleColumn is: " +
        workflowProperties.Item["SampleColumn"];
        SPWorkflow.CreateHistoryEvent(workflowProperties.Web, WorkflowInstanceId, 0, workflowProperties.Web.CurrentUser, new TimeSpan(), "Update", comment, string.Empty);
    }
    
    private void onWorkflowItemChanged1_Invoked(object sender, ExternalDataEventArgs e)
    {
        var comment = "Workflow continous!, item Title is: " +                           workflowProperties.Item["SampleColumn"];
        SPWorkflow.CreateHistoryEvent(workflowProperties.Web, WorkflowInstanceId, 0, workflowProperties.Web.CurrentUser, new TimeSpan(), "Update", comment, string.Empty);
     }
    

    And workflow itself

    Workflow screenshot

    If you had something different, please let me know. I had myself some problems with declarative workflows which were running on SharePoint library and most of the time i was not able to find nice solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experiencing a strange issue where my Visual Studio 2005 C++ program crashes the
I've experiencing some troubles when running applications in Visual Web Developer 2010 with the
I am experiencing a minor difficulty. I have a webpage, and have created a
When experiencing networking problems on client machines, I'd like to be able to run
I am experiencing a fatal error while using artisan on the (fantastic) Laravel PHP
After experiencing some performances issues on my client side, we decided to give a
Currently I'm experiencing a little logical problem. Assume I have an object where I
I am experiencing difficulty with the following VBS code. It works only sometimes, and
I'm experiencing a difficulty in rendering sfWidgetFormDoctrineChoice (set of checkboxes) widget for a NestedSet
I'm experimenting with MongoDB using the PHP PECL extension, however I'm having difficulty getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.