Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Integer column refuses to update View modes: 
User avatar
Member
Member
Chanan - 3/15/2011 11:07:07 AM
   
Integer column refuses to update
I am trying to update the data for the current node. I have no problem updating a text field, but when I try to update a integer field it refuses to update.

I tried looking with SQL Profiler and it seems to me that if I use SetIntegerValue the SQL gets written without that field being updated (it still has the old value). If I use SetValue the SQL doesn't get fired at all.

Here is some sample code:

var ui = UserInfoProvider.GetUserInfo(CMSContext.CurrentUser.UserName);
var tree = new CMS.TreeEngine.TreeProvider(ui);
var node = tree.SelectSingleNode(CMSContext.CurrentPageInfo.NodeId);
var approvals = node.GetIntegerValue("Approvals");
//node.SetIntegerValue("Approvals", approvals--, true);
node.SetValue("Approvals", Convert.ToString(approvals--));
node.SetValue("Title", approvals.ToString()); //For testing purposes - update the title
node.Update();


User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/21/2011 5:00:02 PM
   
RE:Integer column refuses to update
Hi,

could you please find an inspiration in the following C# code. The int value was set without any issue, therefore maybe you could try to replace var declaration with following:

// tree provider
CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS.CMSHelper.CMSContext.CurrentUser);

// get document with specified site, alias path and culture
CMS.TreeEngine.TreeNode node = provider.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/aliasPath", "en-us");

if (node != null)
{
// change int value
node.SetIntegerValue("IntegerNumberAttributeTypeField", 500, true);

// Update the document
node.Update();
}


Best regards,
Ivana Tomanickova