Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Custom Document Type not Updating View modes: 
User avatar
Certified Developer 13
Certified Developer 13
jay@3degreesnorth.com.au - 8/8/2013 5:42:55 PM
   
Custom Document Type not Updating
I have some code that gets loads a custom document type - attempts to update some field values and then calls Update. However the Update doesn't seem to be pushing the changes back to the database.

I'm using these commands to update the properties:
nodeInstance.SetValue("PriceAffiliate", 0);
nodeInstance.SetValue("PriceSpecial", 0);

And then calling

nodeInstance.Udpate();

I've run a SQL trace and there's no attempt to update the tables in the db at all.

Any suggestions?

Thanks

Jay

User avatar
Member
Member
kentico_sandroj - 8/8/2013 9:22:53 PM
   
RE:Custom Document Type not Updating
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;
}

User avatar
Certified Developer 13
Certified Developer 13
jay@3degreesnorth.com.au - 8/9/2013 1:08:37 AM
   
RE:Custom Document Type not Updating
Found my problem.

I wasn't loading the TreeNode using the document type class - and so it wasn't finding anything to update.

Fixed now.

Thanks