Skip to content

Instantly share code, notes, and snippets.

@JamesSkemp
Created November 13, 2014 21:35
Show Gist options
  • Save JamesSkemp/f4c32b090b4942bffa38 to your computer and use it in GitHub Desktop.
Save JamesSkemp/f4c32b090b4942bffa38 to your computer and use it in GitHub Desktop.
Sitecore Workflow State History
use xxx_Master
-- Get workflow state names, ids, and counts
/*
select i2.Name, wh.NewState, count(*)
from WorkflowHistory wh
left join Items i2 on wh.NewState = i2.ID
group by i2.Name, wh.NewState
*/
-- Get the last items in a particular workflow state
select top 100 i1.Name AS OldState, i2.Name AS NewState, IsNull(i3.Name, '--Item was deleted') AS ItemName, wh.[Date], wh.[User], wh.ItemID, wh.[Version]
from WorkflowHistory wh
left join Items i1 on wh.OldState = i1.ID
left join Items i2 on wh.NewState = i2.ID
left join Items i3 on wh.ItemID = i3.ID
where NewState = '{BD6CD03D-A022-401B-A8B3-B2AD3928EAAB}'
order by [Date] desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment