Finding the page id for a property value in Extension 2.6

by Viktor 27. January 2009 08:46
Today I had to find on what page in EPiServer a Extension property string was set to a specific value and to do this I had to write four select statements to match fkID and pkID all the way up to the table extVariantData witch holds the holy grail, the EPiServerPageID. As this was not the first time this happend I wrote this stored procedure to make this task easyer. This stored procedure is only tested on EPiServer 4.62 and Extension 2.6 and will not work with EPiServer CMS and X3.
CREATE PROCEDURE FindExtensionData
    @BooleanValue BIT=NULL,
    @Number INT=NULL,
    @FloatNumber FLOAT=NULL,
    @PageType INT=NULL,
    @PageLink INT=NULL,
    @StringValue NVARCHAR(1500)=NULL,
    @LongString NTEXT=NULL,
    @DateValue DATETIME=NULL
AS
BEGIN
    SET NOCOUNT ON;

    SELECT EPiServerPageID
    FROM extVariantData
    WHERE ID IN
    (
        SELECT VariantID
        FROM extInnerTemplateData
        WHERE ID IN
        (
            SELECT InnerTemplateDataID
            FROM extContentBlockData
            WHERE ID IN
            (
                SELECT ContentBlockDataID
                FROM extPropertyData
                WHERE
                    (@BooleanValue IS NULL OR BooleanValue=@BooleanValue) AND
                    (@Number IS NULL OR Number=@Number) AND
                    (@FloatNumber IS NULL OR FloatNumber=@FloatNumber) AND
                    (@PageType IS NULL OR PageType=@PageType) AND
                    (@PageLink IS NULL OR PageLink=@PageLink) AND
                    (@StringValue IS NULL OR StringValue LIKE @StringValue) AND
                    (@LongString IS NULL OR LongString LIKE @LongString) AND
                    (@DateValue IS NULL OR DateValue=@DateValue)
            )
        )
    )

END
GO
If you want to search a string just call the SP with the @StringValue or @LongString set to the string your looking for (you can use wildcards). If you look for a function pointing to a specific page call the SP with the @PageLink argument set to the EPiServer PageID.

Tags: , ,

blog comments powered by Disqus

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 2.5 Sweden License.


Welcome to the Dropit blog!

Here we, the people that work at Dropit, will write about stuff that interests us. For example web development, especially with .NET and EPiServer - but we'll also talk about other techniques that interest us, marketing on the web, social phenomenons, pop culture, games and software development in general.