Ours is a publishing portal. Max time it works, but there are instances when it does not work.
There are few documens in our doc library for which expiration date is less than current date, still they moderation status is approved!!!!
Could you please suggest what may be the reason for this ?
to expire few pages with our code, we shedule the page to current time + 1 minute by a timer job. max times it works fine, but there are few instances for which page file keep checked out by system account infinitely.sample code:-
/// Expires the page by setting the Scheduled End Date to Current Time + 1 minute
/// <param name="item">SPListItem that needs to be scheduled to expire</param>
/// <param name="pagesLibraryUrl">Pages Library URL in the Site Collection</param>
private static void ExpireExistingPage(SPListItem item)
ScheduledItem scheduledItem = null;
scheduledItem = ScheduledItem.GetScheduledItem(item);
if (scheduledItem.ListItem.Properties["PublishingExpirationDate"] == null || DateTime.Parse(scheduledItem.ListItem.Properties["PublishingExpirationDate"].ToString()) > DateTime.Now)
scheduledItem.EndDate = DateTime.Now.AddMinutes(1);
string expireSuccessfullMsg = string.Format(EXPIRE_SUCCESSFULLY_MSG, item.ContentType.Name, item.Title);
catch (Exception ex)
Reply1 by http://social.technet.microsoft.com/profile/aryan30/?ws=usercard-mini
Possible reason of some pages not expiring could be that you might have been setting the wrong time in End Date field and doing System Update after that.
Can you try by updating (using System Update)the end date in past say 1 day before and check whether sharepoint expires that page.
Another reason could be some particular field within sharepoint didn't got updated during updation of time (due to some async moss event or something like that).
Can you try by removing all other code from your code except setting of end date. Do you still find some pages which didn't expired?
Seems to be some trick of asynchronus moss events which are overlapping with each other. Trying giving sleep time b/w these events and check if Checked out error gets solved.Sleep time should vary from 1-4 secs.