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?