When setting publishing start and end dates on a publishing page, these dates will be saved in the PublishStartDate and PublishEndDate fields of the publishing page. Changing the scheduling settings will result in an immediate change of the page (with the modified by and modified date properties set as well), regardless of the state of the page (draft, pending, etc.).
An interesting anomaly I have faced recently (and the source of this discovery) was that when using custom field controls to values of some custom fields and trying to access the values of PublishStartDate or PublishEndDate, these fields contain the values that were present on the ListItem when the pagelayout used to edit the publishing page has loaded.
So imagine the following flow of user actions:
At this point I would expect that the following code would return the dates set in step 3:
1: public override object Value
5: SPFieldDateTime pubStart = base.Fields.GetFieldByInternalName("PublishStartDate") as SPFieldDateTime;
6: return ListItem[pubStart.Id];
10: base.Value = value;
Interestingly this is not the case, the values set in step 3 are not retained. My logic would tell me that the ListItem object would be built from scratch at step 5 resulting in the query of properties (changed in step 3). Any ideas what’s happening here?
Here is what I do:
SPListItem listItem = SPItemProperties.ListItem;
ScheduledItem scheduledItem = ScheduledItem.GetScheduledItem(listItem);
var startDate = scheduledItem.StartDate;
var startDate = scheduledItem.EndDate;