1

I want to query the Final renderings fields for an item in Sitecore directly against the database to check if they have ever had values. I have created the following query but want to be sure it's correct:

SELECT TOP 1 [Id],
      [ItemId],
      [FieldId],
      [Value],
      [Created],
      [Updated],
      [DAC_Index]
FROM [VersionedFields]
WHERE fieldid = '04BF00DB-F5FB-41F7-8AB7-22408372A981'
AND ItemId = '947EBF93-E9F2-4C12-8BC3-78B75B595428'

My query doesn't return any results for this item but I'm assuming this is because it has never had any renderings added to the page or edited and it is just using the renderings set on the standard values of my page template.

Also I would like to do a similar query for the renderings field but I don't get any results for this either so wanted to be sure this query is also right:

  SELECT TOP 1 f.[Id],
     [ItemId],
     [FieldId],
     [Value],
     f.[Created],
     f.[Updated],
     f.[DAC_Index],
     i.Name
 FROM [SharedFields] f
 INNER JOIN [Items] i ON f.itemid = i.id 
 WHERE fieldid = 'F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E'
 AND ItemId = '947EBF93-E9F2-4C12-8BC3-78B75B595428'

I'm doing these queries as I want to see if my page item has ever had any renderings set in experience editor in the database backups I have - or if it just has the values from standard values and it's never been updated.

Further Information: Sitecore 8.1 update 2

To be clear the question I need to answer is: do these queries confirm my page has never had any updates to the renderings?

8
  • Why the INNER JOIN on your second example? [SharedFields] holds both the FieldId and ItemId you would require.
    – Mark Cassidy
    Commented Oct 17, 2016 at 12:15
  • @MarkCassidy I wanted to see what the name of the items were - I excluded my item id in the from originally and had 'select 100' , as I was wondering for which items do have the renderings field set and which don't. It seems in most cases it's __Standard Values on templates and wffm fields - which makes sense I think. Commented Oct 17, 2016 at 12:20
  • Ah right; ok. Well your query looks correct to me; assuming that ItemId is the one you want to investigate.
    – Mark Cassidy
    Commented Oct 17, 2016 at 12:21
  • Just tried both queries and they do return values (for an item that has a rendering/final rendering)
    – Gatogordo
    Commented Oct 17, 2016 at 12:21
  • Can't you test by creating a new item - test the queries - add some renderings - test queries again - remove all renderings - test queries again?
    – Gatogordo
    Commented Oct 17, 2016 at 12:26

1 Answer 1

2

The above queries are correct for checking for any renderings that have not been set by standard values. For those set my standard values only the queries will return no results. If the page has been edited in content editor or experience editor then results will be returned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.