I have been developing a solution for a client that involves the following lines of code, to create a new file inside a document library:
metadata["SomeField"] = someFieldValue; metadata["Title"] = documentTitleValue; var filePath= Guid.NewGuid().ToString("N") + ".docx"; var file = pastaEdicao.Files.Add(filePath, fileContent, metadata, false); var newItem= file.Item;
The code works, or has worked for a few weeks. This project is being developed as a side project for a larger solution that was assigned to another company.
I have linked the callout menu to the Title column and thus the users interact with the files through the document titles as opposed to the file name. At the end of a workflow the file is assigned a proper name and the change is seamless to users.
A recent 'something' slowly made this code stop working in the testing and pre-production servers. It still works in production and in the development server (which only I use and does not have any part of the other company's solution).
First it happened in the test server, new files stopped having their title set, whilst the rest of the metadata were filled in correctly.
A few days later this behavior was replicated to the pre production server. It has yet to reach production, but I fear that it's a matter of time.
I have not made any changes to the file creation process since it was deployed to any of the servers (and am the only person working on this part of the project).
The fact that it started in an environment and then made its way into another makes me think of it being caused by something deployed by the other consulting company as part of their solution. Everyone has said that there were no changes during the specified period (who are they kidding? - happened near xmas and new years narrowed down to a 2 hour period)
I am honestly stumped and don't know what else to look into. Does anyone have any idea what might have been done to break this?
I am using the HashTable overload of the method to avoid conflicting with the workflow, that starts on file creation and sets the status column. If I update the Title field of the new item after creating it, the workflow crashes due to update conflict.
I noticed through a remote debug session that the information is part of the SPFile.ListItemAllFields.Xml properties, but for some reason it is not being mapped to the title. The values are set as " Title:SW|Durp".
It is a multi-lingual server and I have tried variations of the Title column (went as far as adding all of them). I have not tried SPBuiltinFieldID.Title since the hashtable takes only strings as keys.
Through the interface, the Title column does not appear to have been renamed.
The Title field can be updated manually afterwords and all works great.
I am bullheaded about making too drastic changes to the code without understanding why this is happening ._.