Getting an error when trying to move a document and assign metadata. Below is the code I am using -- I receive an error 'Invalid Request' from the Laserfiche response.
using (Session mySess = new Session()) { RepositoryRegistrationCollection repoRegColl = myServ.GetRepositories(); RepositoryRegistration myRepoReg = repoRegColl[LFServerRepository]; if (myRepoReg == null) { myRepoReg = new RepositoryRegistration(LFServerName, LFServerRepository); } mySess.LogIn(user, pwd, myRepoReg); FolderInfo folder = Folder.GetFolderInfo(destFolderId, mySess); //Folder 22201430 will not change foreach (var externalDocumentId in externalDocumentIds) { //Get document info -- 21997011 = Current document m DocumentInfo doc = Document.GetDocumentInfo(externalDocumentId, mySess); //Enter your document ID here //Get folder info -- This will be static, you will ALWAYS move to this folder ID //Initiate the move in Laserfiche -- Autorename the document if name already exists doc.MoveTo(folder, doc.Name, EntryNameOption.AutoRename); //Get existing field values so that we do not overwrite existing data FieldValueCollection FVC = doc.GetFieldValues(); //Lock the document so no other users attempt to open the file //doc.Lock(LockType.Exclusive); //Add the field values, the first section is the field name, then the second is the value we're passing if (parentDocumentId > 0 && parentDocumentId != externalDocumentId) { if (FVC.Any(c => c.Key == "Parent ID")) FVC["ParentID"] = parentDocumentId; //Parent Document Id laserfiche will append this child document to parent else FVC.Add("ParentID", parentDocumentId); } else parentDocumentId = externalDocumentId; FVC.Add("Username", userName); //STRING FVC.Add("DateTime", DateTime.Now); //DATETIME FORMAT TIME USER CHECKED DOCUMENT IN if (!string.IsNullOrEmpty(shipmentId)) { FVC.Add("Document Type", "BOL Code"); //STRING //THIS MUST BE IN S####### FORMAT OR IT WILL FAIL if (FVC.Any(c => c.Key == "Shipment ID")) FVC["Shipment ID"] = shipmentId; else FVC.Add("Shipment ID", shipmentId); } doc.SetFieldValues(FVC); //Save & Unlock document doc.Save(); //doc.Unlock(); }
Please let me know where I am going wrong.
Thanks,
Nate