Temple
Temple

Reputation: 1079

Scheduled publishing of sharepoint listitems

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?

Upvotes: 1

Views: 1758

Answers (3)

Punit Vora
Punit Vora

Reputation: 5188

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

Upvotes: 0

Hugo Migneron
Hugo Migneron

Reputation: 4907

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>

Upvotes: 1

Steve Danner
Steve Danner

Reputation: 22158

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.

Upvotes: 1

Related Questions