Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ScheduledItem.StartDate property

Gets or sets the Coordinated Universal Time (UTC) at which this ScheduledItem object becomes a visible part of the published Web site.

Namespace:  Microsoft.SharePoint.Publishing
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)
public DateTime StartDate { get; set; }

Property value

Type: System.DateTime
The Coordinated Universal Time (UTC) at which this ScheduledItem becomes a visible part of the published Web site.
ExceptionCondition
[System.ArgumentNullException]

The parameter cannot contain a a null reference (Nothing in Visual Basic) value.

[Microsoft.SharePoint.SPException]

The current user does not have sufficient permissions to perform this action.

A value of January 01, 1900, indicates that an instance of the ScheduledItem class has a start date that is set to a past date and should be published immediately after it is approved. If the start date is set to January 01, 1900, the property is displayed as "Immediately" in the corresponding user interfaces.

To save changes after you set this property, call the ScheduledItem.LIstItem.Update method.

The date and time that are returned by this property can be converted from UTC to local time in server-side code using the SPRegionalSettings.TimeZone.UTCToLocalTime(DateTime) method.

The user must have edit permissions on the PublishingPage to set this value. The user must have view permissions on the PublishingPage to initially retrieve the PublishingPage and get any of its property values.

This sample sets a start and end date for a ScheduledItem object and schedules the item so that it is published when the start date is reached and it is unpublished when the end date is reached.

Before compiling and running this sample, verify that the SPListItem is a list item in a document library that supports scheduling.

using ScheduledItem = Microsoft.SharePoint.Publishing.ScheduledItem;
using SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType;
using SPListItem = Microsoft.SharePoint.SPListItem;
using DateTime = System.DateTime;

namespace Microsoft.SDK.SharePointServer.Samples
{
    public static class ScheduledItemCodeSamples
    {
        public static void SetDatesAndSchedule(SPListItem listItem, 
          DateTime startDate, DateTime endDate)
        {
            // Set the input parameter values with
            // your own values.
            
            //
            // validate the input parameters
            if (null == listItem)
            {
                throw new System.ArgumentNullException("listItem");
            }

            // Get the ScheduledItem wrapper for the SPListItem
            // that was passed in.
            //
            ScheduledItem scheduledItem = null;
            if (ScheduledItem.IsScheduledItem(listItem))
            {
                scheduledItem = ScheduledItem.GetScheduledItem(listItem);
            }
            else
            {
                throw new System.ArgumentException
                  ("The document library containing this SPListItem must support scheduling", 
                  "listItem");
            }

            // Set and save the date values.
            scheduledItem.StartDate = startDate;
            scheduledItem.EndDate = endDate;
            scheduledItem.ListItem.Update();

            // Schedule the item so that the StartDate and EndDate
            // take effect.
            scheduledItem.Schedule();
        }        
    }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.