views:

189

answers:

3

I know its possible to schedule pages for publication in SharePoint 2007. Is it also possible to do this for listitems?

For example, a list of links to news stories. Could these be scheduled for future publication? If so, how?

+1  A: 

You could run a Windows Service or a scheduled task to push list items to the SharePoint site on the desired schedule using the object model or the lists web service.

Steve Danner
Its not really what i had in mind but i can see it would work. Was hoping for an out of the box mechanism :(
Temple
+1  A: 

You could add a "publication date" field in your list (assuming it's a list you can add fields to) and then modify your list view to only show items for which the publication date is in the past.

Just modify the section of you schema.xml to something like :

    <Query>
      <Where>
        <Leq>
          <FieldRef Name='publication_x0020_date'/>
          <Value Type='DateTime'>
            <Today />
          </Value>
        </Leq>
      </Where>
    </Query>
Hugo Migneron
Again, not quite what i had in mind but can be used to meet the requirement out of the box.
Temple
A: 

You can create a field in your list, say PublishDateTime, and whenever you add an item to the list, set the future PublishDateTime for it. Then you can use a SharePoint Timer job to keep looking at the list at fixed times and change the item state from say Hidden to Published based on the PublishDateTime. The Microsoft.SharePoint.Administration.SPJobDefinition class is used to do this. Override the execute method of this class and write your code in it.

    public class PublishingJob : SPJobDefinition
    {
    //implement the required constructors.

    //then override Execute method
     public override void Execute (Guid Id) 
     {
      //get current list from web
      foreach(SPListItem item in SPList.Items)
      {
      if(item.PublishDateTime <DateTime.Now)
       {
          item["Published"] = 1;
       }
     }
    }   
   }

See detailed example at Andrew Connells blog

desigeek