We are having a major issue on SharePoint 2019. We have a web service that updates a template file for the user. The next user receives a task with a link to the document so they can verify the automated changes are correct. However when the user clicks the link a message appears at the top stating "A newer version of this document is available on the server. Do you want to work on the most recent version" - they don't have an option to open the most recent version only to discard changes and work on the older version. None of the automated changes are available on the version of the document the user is able to view.
If the user goes into the library and clicks the document the same issue. However if the user selects download and opens the saved document all the changes are available. The user would then be required to make the changes and reupload the document instead of just being able to make a quick change and save the document. This presents many issues, first being that most of our end users do not have direct access to the library. Second it prevents the users from quickly verifying their changes and moving things along in the system. It also means users receiving a link to the document are not able to view the latest version.
How can we fix this issue? When the automated web service updates the document the following code is implemented:
SPFolder oLibrary = oWeb.Folders[sDocLib];
String sFileName = System.IO.Path.GetFileName(sDocPath);
Stream streamModifiedDoc = File.OpenRead(sDocPath);
byte binFile = newbyte[streamModifiedDoc.Length];
streamModifiedDoc.Read(binFile, 0, binFile.Length);
Hashtable docMetaData = newHashtable();
oWeb.AllowUnsafeUpdates = true;
SPFile spfile = oLibrary.Files.Add(sFileName, streamModifiedDoc, docMetaData, true);
oWeb.AllowUnsafeUpdates = false;
Am I missing something that will allow the link to go to the correct version?