Hello,
Are you using workflow? Would it be possible to post the full code?
private bool GetAndUpdateDocuments()
{
// Create an instance of the Tree provider first
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
// Prepare parameters
string siteName = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example/%";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = "CMS.MenuItem";
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
// Fill dataset with documents
DataSet documents = DocumentHelper.GetDocuments(siteName, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, tree);
if (!DataHelper.DataSourceIsEmpty(documents))
{
// Create a new Version manager instance
VersionManager manager = VersionManager.GetInstance(tree);
// Loop through all documents
foreach (DataRow documentRow in documents.Tables[0].Rows)
{
// Create a new Tree node from the data row
TreeNode editDocument = TreeNode.New(documentRow, "CMS.MenuItem", tree);
// Check out the document
manager.CheckOut(editDocument);
string newName = editDocument.DocumentName.ToLower();
// Change document data
editDocument.DocumentName = newName;
// Change coupled data
editDocument.SetValue("MenuItemName", newName);
// Save the changes
DocumentHelper.UpdateDocument(editDocument, tree);
// Check in the document
manager.CheckIn(editDocument, null, null);
}
return true;
}
return false;
}