Zieglers

Just little about C#, .NET, SQL Server 2005, MOSS and SAP

Custom Document Expiration Policy – Part-4: Managing Expiration

Posted by zieglers on January 28, 2010

In this post, i’ll try to show how expiration warnings can be managed. Basically managing warnings includes some custom menu actions such as:

  • Collect Documents - When this action is selected, selected documents are flagged so that they are forced to expire immediately. (Here immediately actually means ‘next time Expiration Timer Job runs’). In other words, selected documents are deleted next day. (Usually expiration timer job runs at 11pm)
  • Reset Expiration Dates – When this action is selected, Last Modified Date of documents are set to Now, so that expiration formula runs again and ExpirationDate field of document is updated based on the formula defined. (ExpirationPeriod and ExpirationWarning values can be set in Web.Config. I’ll also show that in this post)

As I mentioned in previous post (http://zieglers.wordpress.com/2010/01/18/custom-document-expiration-policy-part-3-additions/) of ‘Custom Document Expiration Policy‘ posts series, once documents are in expiration warning period, a list entry is created in Expiration Warnings List. From this list, using Actions menu items you can manage document expiration as mentioned above.

Demo: In our demo, i upload a document to a library for which expiration policy has already been applied.

 

I set ExpirationPeriod value to 5 mins and ExpirationWarning value to 3 mins in web.config for that web.

This means after 2 minutes, document i upload will be in Expiration Warning Period and a warning entry will be created in Expiration Warnings list.

Now, I enable ‘Multiple Item Selection’ feature for this library. This feature is necessary if we want to process more than one item in bulk. Item selection can be enabled/diabled using custom actions menu item as shown below.

Once you enable item selection, you’ll see a checkbox next to each list entry, so that you can select multiple items to process. (Cool,eh?!? This is actually achieved by using JQuery. I’ll also try to show details of it in another post. Stay tuned…)

Reset Expiration Dates:

Let’s select above item and, for instance, let’s reset expiration date for that document. In order to do so, after selecting the item, i click ‘Reset Expiration Dates’ custom actions menu item.

Then, i get a nice pop-up message to confirm this operation.

… and i click OK, so that expiration date of this document gets resetted.

Please take a careful look at above screenshot and first screenshot of this post.

You’ll see that in first screenshot, Last Modified time is 3:39pm and Expiration time is 3:44pm. Then, i resetted expiration date for this document at 3:44pm, as a result of this Expiration time in above screenshot is 3:49pm, which is 5 minutes later than last modification time.

This shows us that once i clicked ‘Reset Expiration Dates’, expiration date was calculated again based on our custom defined expiration formula.

Collect Documents:

Collect Documents action is to force documents to expire immediately. This is achieved by setting a boolean field CollectMe to Yes. Also Expiration Date field is set to Now.

Since in my demo environment, i have set up Expiration Timer Job to run every minute, when i check document library after one minute, I see that my test document is deleted/collected.

Here is a demo of how it works:

Similar to Reset Expiration Dates scenario, first I upload my test document.

Then, after 2 minutes, when document is in Expiration Warning Period, warning entry is created in Expiration Warnings List.

Once again enable item selection and select test document.

Then, go to Actions Menu and select “Collect Documents-To-Expire“.

 

At this point CollectMe field is set to YES and Expiration Date field is set to Now. When we go to document library we can see updated fields as shown below.

Also note that Modified and Expiration Date field values are same, which tells us that Expiration Date is set to Now.

Finally, checking the document library after 1 minute, I see that expiration occurred and my test document is deleted/collected. (Moreover, another log entry is created in Expiration History list for this expiration event.)

So, this concludes Managing Expiration post.

Please let me know if you have any suggestions/comments re usability/functionality of Expiration Management feature.

Zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , , , , , , | Leave a Comment »

Custom Document Expiration Policy – Part-3: Additions

Posted by zieglers on January 18, 2010

This post will detail some functional extensions implemented for Custom Expiration Policy.

You can find previous posts related to Custom Expiration Policy here:

Previously, we implemented our custom expiration policy to take advantage of OOTB delete action. This means when a document expires, it is simply deleted.

In this post we’ll look into details of how to perform a custom action when document expires. Here are the requirements for custom action:

  • First, log expiration warning details to a list called Expiration Warnings.
  • Then, upon expiration, log expiration details to a list called Expiration History.
  • Finally, delete document.

So, that’s how Expiration Warnings and Expiration History lists look like.

Once our custom expiration action is deployed, it shows up in expiration settings under ‘Perform this action‘ dropdown list. I called it ‘Expiration Event Logger‘.

Implementation of custom expiration action is similar to implementation of expiration formula calculation. All we need to do is to implement IExpirationAction interface which can be found in Microsoft.Office.RecordsManagement.PolicyFeatures namespace.

Above OnExpiration method is called once document expires. Here, first we are creating Expiration History List and then deleting the expired document.

In order to create a list and write an entry in it, i used a helper class called ExpirationHistoryList, whose implementation can be seen below.

There is only one constructor. This constructor gets Expiration History List object if created. If it’s not created yet, it creates one.

In addition, WriteEntry method creates log entry in the list along with expiration event details such as document title, list name, web title, … etc.

That concludes this post – logging functionality for expiration policy.

Things to do next: Managing document expiration once expiration warning period is reached using Expiration Warnings list.

Zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , , , , , | 1 Comment »

Custom Document Expiration Policy – Part-2: Implementation

Posted by zieglers on January 18, 2010

In my previous post (http://zieglers.wordpress.com/2010/01/18/custom-document-expiration-policy-part-1-overview/), i tried to show how custom expiration policy works. Now in this post, i’ll dive into implementation details.

Here what we do is to create and install our own expiration formula as Policy Resources that are linked to the Expiration Policy Feature.

The Expiration Policy Feature communicates with your custom expiration formula policy resource through a special interface provided for that purpose. The IExpirationFormula interface is declared in the Microsoft.Office.RecordsManagement.PolicyFeatures namespace. This interface declares a single method that is called to compute the expiration date for a given list item.

Policy Namespace Overview

The following figure shows the organization of the major classes of the information policy object model, located in the Microsoft.Office.RecordsManagement.InformationPolicy namespace. The top-level object, PolicyCatalog, represents the catalog containing the site-level Policy and IPolicyFeature collections.

Most of the properties of the various objects are read-only, and cannot be set programmatically. The properties of the various information policies, policy items, policy features, and policy resources are set in the XML specified when the objects are initially added to Office SharePoint Server 2007.

Each Policy object represents an information policy defined for the site and, in turn, includes a collection of PolicyItem objects.

Similarly, each PolicyFeature object represents an installed policy feature, and contains a collection of the PolicyResourceType object that the policy features can use, as well as a collection of the actual policy resources currently installed for the policy feature; each of these policy resources is represented by a PolicyResource object.

The following figure shows the information contained within the Policy Feature Definition, and the items that the information references.

I think above information clears the overall picture. Now let’s see the implementation of IExpirationFormula interface.

Here we need to implement only one method, which is ComputeExpireDate. You can implement your own custom logic to calculate expiration date here and then return it. As for this POC, my custom logic is as follows:

1. Check for existing expiry date, if there is any.

2. If there is, compare it with current time. If time difference is less than 2 minutes, send a warning email to user.

3. If there is no existing expiry date, set it based on following rule:

[Extra Functionality] if user wants this item to be collected immediately (if ‘CollectMe‘ field value is Yes – assuming that there is a Yes/No column called CollectMe in the library), then set expiration date to current time.

if CollectMe is No, then set expiration date to 5 minutes after last modification time.

Pretty straightforward, right? Note that this function will be called each time Expiration Timer Job runs and each time this list item is edited.

Also, here is the snippet of SendWarningEmail helper method. This code is just for demonstration, values are hardcoded, but it shows how to use SPUtility.SendEmail method.

Well, that’s all about it.

Zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , , , , , , | 1 Comment »

Custom Document Expiration Policy – Part-1: Overview

Posted by zieglers on January 18, 2010

In this post, i’ll try to mention what ‘Custom Expiration Policy‘ is and how you can develop one for your needs.

SharePoint comes with ECM (Enterprise Content Management) capabilities and probably most important building block of ECM is ‘Policies‘. They are also called IMPs (Information Management Policy) withing SharePoint domain. OOTB ones are Labels, Auditing, Expiration and Barcodes. In this post i’ll focus on Expiration Policy, why we need to customize it and how it can be customized.

SharePoint definition of Expiration Policy: “Automatic scheduling of content for processing, and expiry of content that has reached its due date.”

Simply saying ‘Set an expiration date on documents. Once due date is reached, perform an action.’ Here, the main parts are Expiration Date and Action Performed once document expires.

MOTIVATION: Customization need comes into play right at this point. OOTB SharePoint functionality only allows you to set expiration date based on two fields: Created Date and Modified Date. In real life scenarios, setting an expiry date only based on those two fileds may not be sufficient. Also, you might want to do some custom checks or look-ups while setting this date. Another important requirement leading to customization can be the necessity of sending warning emails before document expires.

Hence, I developed a POC to demonstrate how Custom Expiration Policy works.

POC Requirements: POC scenario is really simple.

  • Set Expiration Date to Last Modified Date + 5 mins.
  • Send warning email within last 2 mins. (This is customization part).
  • Delete document when it expires.

POC in ACTION: Now, let’s see how it works.

To test custom expiration policy, i created a test document library called ‘Test’ and defined a policy for this library in ‘Document Library Settings > Information Management Policy Settings’.

Define a policy…

Here enable expiration policy and select custom expiration formula as shown below.

You’ll notice that there is an additional entry for retention period choice, which is “Set by a custom retention formula installed on this server“. Our custom formula name is “SomeCompanyName Custom Expiration“. This entry shows up once you deploy your custom policy resource. We’ll get back into details later about that.

Now, let’s upload a test document to library.

As you can see above, Expiration Date is set to Modified + 5 minutes by our custom expiration formula.

So far so good. Our expectation is now to get a warning email after 3 mins. Normally, SharePoint Expiration Timer Job runs daily between 23:00 and 23:30. But if you don’t want to wait for this you can force it to run in Central Admin.

For demonstration purposes, that’s what i did. Now i check my inbox and here is my warning email. (Message body says “will expire in a month“. Ignore that, since this will be eventually in finalized version of this POC)

Now, I expect to see that document is deleted after 2 mins, which in total makes 5 mins, retention period.

… wait wait wait … one minute passed … wait wait wait … two minutes passed … check test library … :)

Document is deleted!!! Mission accomplished :)

So this completes our ‘Custom Expiration Policy‘ scenario.

I think so far is enough for this post. I’ll try to show implementation details in another post.

Zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , , , , , , | 3 Comments »

Upload as a Zip file

Posted by zieglers on January 15, 2010

This post is actually last section of previous post: Download as a Zip file. Since this post focuses on Upload functionality, I thought it’d deserve it’s own space..

 MOTIVATION: Uploading documents individually to a document library can take some time. Eventhough you use ‘Upload Multiple Documents’ functionality, then you have to select your documents one by one again.

 On the other hand, having the flexibility of uploading a zip file to a document library and expanding documents automatically has advantages over uploading multiple documents:

 One single file is uploaded to server vs. multiple files. This means server is kept less busy and less server resources are consumed.

  • Zip file is smaller in size, because it is compressed. Again this means that uploaded file size is less than sum of sizes of individually uploaded documents.
  • Uploading a zip file is faster due to being small in size.
  • Uploading a zip file is more organized since your zip file will contain a logical set of documents, such as project documents.

Ok, that’s enough motivation so far. Let’s get to action.

 Upload a Zip file to a document library:

Upload a zip file functionality can be initiated using Upload section in toolbar.

Once you select ‘Upload as a Zip file and expand‘, you are taken to upload zip file application page.

Here you browse to the zip file you want to upload. Alternatively, you have 2 extract options: Create Folder for Extracted Files and Keep Original Zip file. (I think they are self explanatory.)

Here I select a zip file called BaseTestDocZ.zip.

Once you click OK, zip file is uploaded to server, files are extracted and inserted to document library as shown below.

… and here is the contents of BaseTestDocZ folder:

Finally that concludes this post. Please feel free to share your thought & suggestions.

Note: I’ll post wsp solution for this post soon!!!

Zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , , , | Leave a Comment »

Download as a Zip file

Posted by zieglers on January 15, 2010

This post is about a new list action feature called ‘Download as a Zip file‘.

MOTIVATION: While using SharePoint document libraries, I’m sure almost all of us, time to time, download bunch of project related documents to local machines and work on them. Due to projects being large-scale, usually number of related documents <half second pause effect> A LOT! :)

In order to get all documents to your local drive, as of now, you need to download those documents one-by-one.

However, imagine the flexibility of downloading your documents as a zip file, wouldn’t that be nice?! I think it would :)  

Well, let’s not think small here, not only individual documents, but we also want to be able to ‘zip’ a folder, which contains bunch of project related documents, right? Hmm, now it starts to sound more useful..

Ok, let’s imagine more. What about (don’t get too excited, that’s the last one) uploading a zip file of your choice and as soon as it’s upload, it’s extracted automatically and all zipped files are inserted into SharePoint document library?!?!

I think so far we have enough motivation for such a solution. Here is how it’s going to look like.

Download File as a Zip file:

Functionality is tied to ECB menu. Simply, right click document you want to download as zip and select ‘Download as a Zip file‘ option as seen below.

 Once you select that option, file is zipped and you are prompted file download dialog box.

Download Folder as a Zip file:

Functionality is also tied to ECB menu. Actualy you do same clicks for downloading a folder as a zip file. Only difference is you right click folder itself instead of going into that folder.

Based on your selection’s internal type – being either file or folder – ecb menu item is calling associated code piece to execute.

Here is an example: We have a test folder called ‘My Test Folder’ as seen below and two test documents in it, namely TestDOC and TestEXCEL.

 Test Folder:

 Test files in test folder:

Just, right click ‘My Test Folder’ and select ‘Download as a Zip file’. Doing so will zip test folder with all files in it and you will be again prompted File Download dialog box.

 That’s it!!! I’ll update the post when I’m done with upload option.

Note: I’ll post wsp solution for this soon!!!

Please share your thoughts, suggestions …etc.

Zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , | Leave a Comment »

Multiple List Search and Process Items

Posted by zieglers on December 3, 2009

Recently, i’ve been looking for a solution to select multiple items from different lists and come up with a ‘Selected Items’ basket in order to further process with either predefined or custom actions. The idea is to be able to select multiple items and compiling a sort of ‘wish list’ or as i called it ‘Processing List’. Then, once items are selected, either to apply bulk operations (like checkin, checkout, approve, delete, download, publish, …etc) on them or some custom code is the way to go.

Here is use case steps for this application page:

Step-1: Select list you want to search

Step-2: Type your search criteria and add item(s) to Processing List below

Step-3: Selected items are listed in ‘Processing List’ repeater

Step-4: Reorder or Remove items to finalize your list. In above shown list, I removed list item and reordered remaining 3 items.

Next application page is ‘Process Items’ page, where you can either write own custom code to process your list or select some bulk operations as shown below.

Here at this point, i need some suggestions. What can be the other possible usage scenarios for this ‘List Search and Process’ tool?

Bulk operations, custom code, applying common metadata, dynamically loading assemblies and calling methods…? That’s all I have in mind so far. In case you have suggestions, please share so that we can make use of this logic for generic purpose.

zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , , , | Leave a Comment »

SharePoint 2010 – one million items in a list

Posted by zieglers on November 21, 2009

Just like most people, i downloaded and installed SharePoint 2010 last week. Unlike mentioned, I had no issues while installing on Windows 2008 R2 environment. It’s been a week and still no issues.

Looks like it’s going to take a while for me to get used to new ribbon interface. Definitely you get to see and do more with ribbon, but will take a some time to remember what is where.

Actually, main focus of this post is a lot mentioned new feature of SharePoint 2010. ”Limitation on number of items stored in a list”  problem seems to be solved – Now, SharePoint lists can handle millions of items.

In order to see this, I decided to do a little experiment. My aim is firstly to insert one million items in a list successfully. As I write this post items are still being inserted, 731371 and still counting… So far it’s been 6 hours and still inserting.

I have to also mention that my experiment environment is done on a  Win 2008 R2 with 2 GB Ram and using an external usb hdd. So this waiting time can be way less if you try with a powerful workstation. Anyhow, how do I insert 1 million items to a list? Of course using PowerShell script..

Here is a very simple PowerShell script which inserts items to a list. This script is just assigning ‘Title’ column values: Item – ItemNo

========================================================================================

// Set site url
$siteurl = “http://yourservername”

// get site obj
$mysite=new-object Microsoft.SharePoint.SPSite($siteurl)

// open root web
$spWeb = $mysite.OpenWeb()
 
// get test list obj
$spList = $spWeb.Lists["TestList"]

// Insert 1 million items
$i = 1001

do { Write-Host “Item – “$i
         $spitem = $spList.Items.Add() 
         $spitem["Title"] = $i.tostring()
         $spitem.Update()
         $i++
}
while ($i -le 1000000)

========================================================================================

Will update this post once insert operation is completed…

(next morning)

Ok, now i see insert operation is completed. As you can see below, one million list items are inserted into a list using PowerShell.

At this point I’d like to do some test re item select/update/delete operations. Also wondering how filtering is going to work in such a large list. If you have suggestions for other tests or things to check, please let me know, i’ll try to apply them as well. At the end, I’d like to have a some sort of comfort level while suggesting a client ‘one million item is ok in a SharePoint 2010 list’.

… to be continued…

zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , | Leave a Comment »

Reading QueryString paramater values using JavaScript in SharePoint

Posted by zieglers on November 13, 2009

Here is a nice javascript snippet which allows you to read querystring parameter values. Actually i used this code in a SharePoint application page to read ListId and ItemId values that i was passing from previous page.

// ************************************************************
// Create an array to keep query string variables
var qsParm = new Array();
// This function gets query string values from current page
// and stores them in above defined array
function qs()
    {
            var query = window.location.search.substring(1);
            var parms = query.split(‘&’);
           
            for (var i=0; i<parms.length; i++) {
                var pos = parms[i].indexOf(‘=’);
                if (pos > 0)
                {
                    var key = parms[i].substring(0,pos);
                    var val = parms[i].substring(pos+1);
                    qsParm[key] = val;
                }
            }
    }

qsParm['ListId'] = null;
qsParm['ItemId'] = null;
// Call function – get query strings
qs();
// For example show ListId
alert(qsParm['ListId'])
// ************************************************************

zieglers

Posted in IT Stuff, SharePoint | Tagged: , , , , | Leave a Comment »

SAP IDES ERP 6.0 EHP4 / NetWeaver 7.01 Installation Guide on Windows 2003 64-bit – Part 2

Posted by zieglers on November 12, 2009

In this 2nd part of the article, I’ll mention installation environment details. Although SAP doesn’t recommend installation on laptops, I did my test installation on a virtual machine. As host machine I used Windows 7 Ultimate 64bit and VMware Workstation. Here are guest 64bit operation system details:

=========================================================================================

Installation Guest Machine details

* Windows Server 2003 R2 – Standard x64 Edition

19

* MS SQL Server 2008 x64 with collation CP850_BIN2 (this is very important. you can only install SAP with this collation)

23

* Java JDK 1.4.2_17 windows-amd 64bit. If you have problems finding a 64bit version for Java 1.4.2_? SDK, here is the link: http://java.sun.com/j2se/1.4.2/SAPsite/download.html

Java SDK versions provided in above link are specific builds for SAP customers. For my installation, I used following version.

20

Also, you should download Java Cryptography Extension 1.4.2 since SAP Installer will ask for it during installation.

==========================================================================================

Starting Installation Process

If you have downloaded all necessary installation media as described in part 1(http://zieglers.wordpress.com/2009/11/10/sap-ides-erp-6-0-ehp4-netweaver-7-01-installation-guide/) and prepared your installation guest machine as described above, now we can start installing SAP IDES ERP 6.0.

… to be continued…

zieglers

Posted in IT Stuff, SAP | Tagged: , , , , , , , | 2 Comments »