Updating value of custom page type field in database not reflected in Form tab

Quang Lai asked on May 12, 2017 19:50

We have a situation where we would like to update a custom page type's field value through a simple database update query. That part was easy, but when we go to the affected document's Form tab in Kentico CMS, the old value is there - it looks like it's not picking up the values from the actual page type's database table, but querying from somewhere else?

We are using v8.2 with a very simple workflow enabled.

Correct Answer

Brenden Kehren answered on May 12, 2017 19:56

Using workflow, you will need to update other tables as well which is not as easy as you think because those other tables store the data as XML in a single column. Your best bet might be to write a simple C# method to go through and loop through all the pages, check them out, update them, check them back in and publish them.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Quang Lai answered on May 12, 2017 20:20

I'm afraid you are right Brenden. :(

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 13, 2017 09:09

Quang, your best bet would be to update these field using Kentico API which internally will take care of firing right triggers to update dependent tables itself.

The problem is though you're updating the table the value when you query comes usually from a view which was not updated.

However using API well take care of this.

1 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 15, 2017 15:41

Hi,
Just to add my 5 cents to Brenden's post, here is a link to the API examples on how to work with pages under workflow: Page's management API

0 votesVote for this answer Mark as a Correct answer

J Anderson answered on June 15, 2017 22:03 (last edited on June 15, 2017 22:09)

I made this mistake on a new project I'm working on.

I imported the pages into Kentico using the Import tool... Enabled a simple workflow to enable archiving and versioning... Then later changed a value in the raw database. The field is correctly displaying on our website, but in the admin, the fields aren't correct.

All I did to fix it was to go to the "Listing" area of Pages, and Archive all the problem pages (Selected the parents, and included children), then Publish them again.

In my case, all the pages were published already, so I didn't have to worry about things that were deactivated... So, keep that in mind, depending on your situation. Also, I did this successfully in v9.0, but i checked an instance I have in v8.1.9, and it seems to have the same options.

0 votesVote for this answer Mark as a Correct answer

Jonathon Stierman answered on May 4, 2018 18:26 (last edited on May 4, 2018 18:32)

I ran into this same issue on my Kentico 11 install. I ended up not updating the database tables directly, and just using the Kentico APIs. Code looks roughly like this:

TreeNode node = DocumentHelper.GetDocuments().OnCurrentSite().PublishedVersion(true).Where("NodeSKUID", QueryOperator.Equals, "MySKUID").FirstOrDefault();
node.SetValue("MyCustomProperty", "My Custom Value");
node.Update();
node.MoveToPublishedStep();
node.VersionManager.SaveVersion(node);

This updates both my custom table and the raw XML version history in the database.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.