Sitefinity ASP.NET CMS - Content Management System
Skip Navigation
Product
Purchase
Support
Partners
Corporate
My Client.net
Support
Get Support
Forums
Documentation
Knowledge Base
Support Options
Webinars
KB Article
Home
>
Support
>
Knowledge Base
>
KB Article
How to apply the new metafields to old items in a module
- ID#
1026
Rating:
Not rated
Last Modified:
6/26/2008
Related categories:
Modules
;
Article information
Article relates to
Sitefinity 3.2
Created by
Georgi Chokov
Problem Description
When you add a new meta field to a module, you will probably notice that it is not applied to your old items (i.e. items added before the meta field existed). You could set a value for this field for all of your items, but you will be able to use Sorting Expressions with the meta field only for the newly created items - the old items are excluded from the sorting list.
The problem occurs because in the
sf_GCMetaData
table where the metakeys are preserved as meta fields, the
CntPrntID
column is somehow saved with null value for the old items. The
CntPrntID
column is actually used to say to the meta field which is the parent of the content. In the Images & Documents for example, it would save the
ID
of the Library which holds the image or document.
Solution
You have to upload/create at least one item after adding the meta field. All items should be saved with Batch Update (for Libraries) or manually, so the new MetaField value will be stored in the database, otherwise there will be nothing to update with the script.
Then run the following script against your database:
update
sf_GCMetaData
set
CntPrntID =
(
select
distinct
CntPrntID
from
sf_GCMetaData
as
meta
where
meta.ContentID = sf_GCMetaData.ContentID
and
meta.LangID = sf_GCMetaData.LangID
and
meta.Application = sf_GCMetaData.Application
and
meta.ContentID = sf_GCMetaData.ContentID
and
meta.CntPrntID
is
not
null
)
where
CntPrntID
is
null
It's a good practice to make a
backup
before database operations and we would recommend doing this.
The script will basically find
CntPrntID
value which is different than null and set it to any null fields of records that apply to the same module.
Article Comments
There are no comments yet.
Please
Sign In
to rate this article or to add it to your favorites.
Print
Send to a Friend