SharePoint SP2 activates 180 day trial countdown

May 22, 2009   9:21


SharePoint SP2 activates 180 day trial countdownThe Microsoft SharePoint Team announced that the SharePoint SP2 service pack by mistake activates a 180-day countdown.

“During the installation of SP2, a product expiration date is improperly activated. This means SharePoint will expire as though it was a trial installation 180 days after SP2 is deployed. The activation of the expiration date will not affect the normal function of SharePoint up until the expiration date passes. Furthermore, product expiration 180 days after SP2 installation will not affect customer’s data, configuration or application code but will render SharePoint inaccessible for end-users.”

The team is working as hard as possible to release a hotfix to address the issue.

The Work around is also known: Re-enter the Product ID numbers on the Convert License Type page in Central Administration.

More information at the Microsoft SharePoint team site.

Tags: , , , , , .





Enable item scheduling by code

May 18, 2009   21:29


Enable item scheduling by codeeI’m developing a site template, which requires item scheduling on the page library. I don’t want our users to enable the item scheduling manually at the “_layouts/ ManageItemScheduling.aspx” page. Unfortunately I was not able to find any online documentation about how to do this with code.

It required me to dig deeper and .Net reflector turned out to be the right way to go. Microsoft made a lot of the required functions internal, which means that we cannot access the functions from our own code. By analyzing the steps I was able to add item scheduling on the pages library with the code below.

Step 1: Enable Moderation and Minor versions
To allow item scheduling, we must enable moderation and minor versions on the pages list.

SPWeb web = new SPSite(”http://web”).OpenWeb();
SPList list = web.Lists["Pages"];

//Enable moderation and minor versions
list.EnableModeration = true;
list.EnableMinorVersions = true;
list.Update();

Step 2: Register Scheduling Events
The item scheduling requires us to register 2 events.
First we will retrieve the assembly and class information of the ScheduledItemEventReceiver and then we will create the 2 events.

//get type information
Type scheduledItemType = typeof(Microsoft.SharePoint.Publishing.Internal.ScheduledItemEventReceiver);
string assemblyName = scheduledItemType.Assembly.FullName.ToString();
string className = scheduledItemType.FullName;

//Get the eventreceivers
SPEventReceiverDefinitionCollection eventReceivers = list.EventReceivers;

//Register the updating event
SPEventReceiverDefinition updateDef = eventReceivers.Add();
updateDef.Name = “Item Updating Event Handler For Scheduling”;
updateDef.Type = SPEventReceiverType.ItemUpdating;
updateDef.Assembly = assemblyName;
updateDef.Class = className;
updateDef.Update();

//Register the added event
SPEventReceiverDefinition addDef = eventReceivers.Add();
addDef.Name = “Item Added Event Handler For Scheduling”;
addDef.Type = SPEventReceiverType.ItemAdded;
addDef.Assembly = assemblyName;
addDef.Class = className;
addDef.Update();

Step 3: Unhide the startdate and expirydate fields
The list already contains the startdate and expirydate fields, but they are hidden. With the following code we will unhide the fields.

//Get the field guids of the startdate and expirydate
Guid startDateGuid = Microsoft.SharePoint.Publishing.FieldId.StartDate;
Guid expiryDateGuid = Microsoft.SharePoint.Publishing.FieldId.ExpiryDate;

//update the visibility of the startdate
SPField startDateField = list.Fields[startDateGuid];
startDateField.Hidden = false;
startDateField.Update();

//update the visibility of the expirydate
SPField expiryDateField = list.Fields[expiryDateGuid];
expiryDateField.Hidden = false;
expiryDateField.Update();

And that’s it. With these coding steps we enabled item scheduling at the Page library.

Tags: , , , , .









The content expressed in this blog are those of Edwin Vriethoff and do not represent his employer's view in anyway. The contents of this blog has been carefully put together, but Edwin Vriethoff is not responsible in any way for any direct or indirect harm caused by individuals or organizations using the content of this blog in any way.