ScheduleStart method (DateTime, Boolean, String)

SPFile.ScheduleStart method (DateTime, Boolean, String)

Schedules the automatic approval of a document in a moderated library at the specified date and time, with the specified approval comment, and optionally changes the moderation status of the list item.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public void ScheduleStart(
	DateTime startDate,
	bool setModerationStatus,
	string approvalComment


Type: System.DateTime

The date and time when the document is approved.

Type: System.Boolean

true to set the ModerationInformation property of the list item to SPModerationStatusType.Scheduled; false to leave the moderation status unchanged.

Type: System.String

The explanation why the item was approved. This method stores this value in the SPListItem.ModerationInformation.Comment property.


The current user does not have the SPBasePermissions.ApproveItems permissions.


The value of the document library EnableModeration property is false.


The value of the document library EnableMinorVersions property is false.


The document is already approved (The value of the ModerationInformation property of the list item is SPModerationStatusType.Approved).


Minor versioning is not enabled for the document library.

This method creates a work-item timer job that calls the Approve(String) method at a specific date and time. If another job of the same type has already been created for the file, it is replaced by this new job. When the specified date and time arrive, the file is approved and published. It then becomes visible in public views of the document library.

Scheduling status is tracked through the ModerationInformation property of the list item. If true is passed as an argument to the setModerationStatus parameter of the ScheduleStart method, the ModerationInformation property is set to SPModerationStatusType.Scheduled. If you do not want to show approval as scheduled, pass false as the argument.

Because the ScheduleStart method essentially approves the file in advance of its publication, the current user must have the SPBasePermissions.ApproveItems permission. When the timer job created by this method eventually executes, the value of the ModerationInformation property of the list item is set to SPModerationStatusType.Approved, and the text string passed as the argument to the approvalComment parameter is set as the value of the list item’s SPListItem.ModerationInformation.Comment property.

Content approval results in the elevation of a minor version of the file to a major version. Only minor versions may be scheduled, and only major versions are published. For this process to work, minor versioning must be enabled for the document library.

This example schedules an approval work item for a file in a document library. The approval is scheduled to take place in the early morning hours on the day after the request.

public void Approve(SPListItem item, string comment)
    SPFile file = item.File;

    // Be sure we have a file to work with.
    if (file != null)
        // Check in any file that is checked out.
        if (file.Level == SPFileLevel.Checkout)
            file.CheckIn(String.Empty, SPCheckinType.MinorCheckIn);

        // Queue it up at 2 am tomorrow.
        DateTime startDate = DateTime.Now.Date.AddHours(2.0);
            file.ScheduleStart(startDate, true, comment);
        catch (SPException ex)
            // Handle Sharepoint errors
© 2016 Microsoft