1

Is it possible to retrieve the fields of an ArchiveEntry type using Sitecore Item API? e.g. archiveEntry.Fields["FieldName"]

2 Answers 2

2

There is no way of get fields of archive entry with Sitecore API.

ArchiveEntry class contains only

  • information about archiving process (date, origin database, who archived the item)
  • original item ID
  • original item name
  • original item location

Archived fields are stored in SQL databases (core, master and web) in ArchivedFields table

When item is archived, all the shared fields, versioned fields and unversioned fields are added to ArchivedFields table, item data is added to ArchivedItems table and after it's done, item itself is removed from the original database.


EDIT to answer question from the comment

Yes, it's possible to get values of archived fields if you query database directly if you know id of the item which is archived. Query like that should do the trick:

SELECT af.[VersionId]
      ,af.[FieldId]
      ,af.[Value]
      ,ai.ItemId
FROM 
  [ArchivedFields] af JOIN [ArchivedItems] ai ON af.ArchivalId = ai.ArchivalId
WHERE
  ItemId = 'B09F6C56-E59B-420F-A669-130ED3A46C3F'
3
  • so it's possible to get the fields if i query directly to ArchivedFields table?
    – Christian
    Commented Feb 9, 2022 at 9:12
  • yes, answer updated
    – Marek Musielak
    Commented Feb 9, 2022 at 9:33
  • thanks. marked answer
    – Christian
    Commented Feb 9, 2022 at 10:23
1

You can use this to provide a more detailed report with SPE.

Import-Function -Name Invoke-SqlCommand

$connection = [Sitecore.Configuration.Settings]::GetConnectionString("master")

$query = @"
SELECT 
    ai.[ItemId]
    ,ai.[Name]
    ,ai.[TemplateId]
    ,ai.[ParentId]
    ,af.[VersionId]
    ,af.[FieldId]
    ,af.[Value]
      
FROM [ArchivedFields] af JOIN [ArchivedItems] ai ON af.ArchivalId = ai.ArchivalId
"@
Invoke-SqlCommand -Connection $connection -Query $query | Show-ListView

Example

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.