Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > New CMS_Class, how to insert via the API View modes: 
User avatar
Member
Member
JAA - 1/30/2014 5:19:17 PM
   
New CMS_Class, how to insert via the API
Im still understanding Kentico ...

Our product has a custom created CMS Class. In the DB I have noticed a table representative of that Class.

I have API code which I want to insert into that table. What I am noticing is that my insert is missing some fields as I get a MySQL error along the lines of:
Message=Cannot insert the value NULL into column 'Code', table 'FOO.dbo.BAR_DocumentType'; column does not allow nulls. INSERT fails.

Here is the example API code which I also know works for standard inserts:
TreeNode parentProject = tree.SelectSingleNode(siteName, "/Projects/" + projectID, "en-us");

TreeNode newDocument = TreeNode.New("BAR.DocumentType", tree);

newDocument.DocumentName = "XXX99v01";
newDocument.DocumentCulture = "en-us";

newDocument.Insert(parentProject);

I know the code is interfacing with Kentico properly as I can step through the debugger and watch the objects.

Is there something special I need to be doing or configure to be able to do this? How can I set values like 'Code' which 'BAR.DocumentType is looking for?

User avatar
Member
Member
JAA - 1/31/2014 12:39:25 PM
   
RE:New CMS_Class, how to insert via the API
I needed to use the SetValue option for making sure each object had the appropriate values.
newDocument.SetValue("Code", "UNK");