Mahesh
Mahesh

Reputation: 2757

Kentico page update not update Physical table

I Have Kentico web site which has scheduler task that synchronise data with external Database. Basically few pages created from external database table. We have two methods for both create and update record in Kentico table.

For create we use

TreeNode page = TreeNode.New(Helper.ClassName_Campus);
page.SetValue("Title", "Title");
page.Insert(parentPage);

Create record works fine and update physical table data.

For update we use

 TreeNode page = DocumentHelper.GetDocuments(Helper.ClassName_Campus).OnSite("site").Where(" ID", QueryOperator.Equals, 1).FirstObject;
 page.SetValue("Title", "Title");
 page.Update();

Update method does works OK. when i go to page and form data i can see new data on the form field, but it doesn't update actual physical table data. How can we update the actual physical data table when updating page. where is Kentico store form data after update.

This is the link we found on kentico web site for update table data. https://docs.kentico.com/display/K9/Working+with+pages+in+the+API

Upvotes: 1

Views: 261

Answers (2)

Enn
Enn

Reputation: 2209

Kentico content tables (the ones bound to a page type) always contain only published data. In case you are using workflow/versioning the "new" data will be stored in CMS_VersionHistory table instead.

The solution is simply to publish the page by using something like:

    var page = DocumentHelper.GetDocument(1, new TreeProvider());
    page.DocumentName = "Update name";
    page.Publish();

Upvotes: 4

Dawid Jachnik
Dawid Jachnik

Reputation: 447

Did you use workflow for this pages?

You can try to using DocumentHelper.UpdateDocument(...) and specify there a TreeProvider, because maybe you don't have permission to update this page.

Here's the link to API how manage the page

Upvotes: 1

Related Questions