Sunday, October 25, 2009

Delete older versions of SharePoint list/library

Just to give you a brief background of why we developed this utility.

Suppose you have accidentally turned on the versioning feature in your document library and you are migrating data from Lotus Notes to SharePoint using any third party utility like Quest Notes migrator for SharePoint and assume you had to re-run the utility again and again on the version enabled document library so as to migrate notes data with full fidelity. What happens then? Many versions of the same document/list item get created.

Assume there are 4000 records which got properly migrated into the versioned enabled document library, but each record created many versions of the same item, as a result average size of each item went to somewhere around 400-500 MB and some of them items were also 1 GB in size.

The site was also deployed into Production. Clients encountered performance issues while accessing items in the document library since the size of the document library had sky rocketed.
What do you do in this case? How do you delete the unnecessary versions and retain only the latest version of the document/list item?

My utility will just do that for you, Delete Item Versions utility will delete older versions of the document library items, while retaining the most recent version of the same. Most of the times, the site is already deployed and running into the production environment, hence , we needed a utility, which can access our production site remotely from any local workstation without touching or deploying anything on the production environment.

We have tested this utility thoroughly and it works like a charm. It uses SharePoint web services and users can run it from their workstations provided they have access to that particular SharePoint webapplication.
We also plan to enhance the features of this utility. Here is a snapshot of the same:

Delete Item Versions
Snapshot of the Delete Item Versions utility
Click here to download the source code.

NOTE: You will have to change the webservice reference in the source code, Build the Project, Test the utility in your test environment and then use the DeleteItemVersions.exe for remotely deleting versions for your SharePoint List/Library.

Feel free to share your comments and ask me in case of any doubts.

I regularly post my SharePoint Insgihts at www.SharePointInsights.com

You can also follow me on Twitter: http://twitter.com/Mehul_Bhuva

Monday, October 19, 2009

What is Web 2.0?

Web 2.0 is not a technology, rather it is a terminology. It means Web as a platform. A platform that brings most of the common user tasks from desktop onto the network or the web.

To be more concise, Web 2.0 is “The power of desktop on the web”. Let me give specific examples:

a. Google Docs/Spreadsheets: Place to create and share online Word docs, Excel spreadsheets, PowerPoint presentations. You don’t need any software’s installed on your desktop, except for a decent web-browser like Firefox or IE. All through the power of Web.

b. Media sharing: YouTube and Meta Cafe are more popular in sharing media resources like Videos, users can now Share, Watch, Videos online, no need for a hard-disk to store videos, everything is on the web and at your finger tips. Slideshare helps users in sharing their presentations online and is very popular in the community.

c. Online File Storage: Want to save folders/files, we have BOX.NET (paid service) which gives 1GB of free space for Free users. Sky Drive is a online file share from Microsoft which gives 25GB of free space for your files/folders. You can create folders, upload files, delete them and share them too.

d. Micro-blogging is at its best these days, as we see Twitter and Yammer flourishing day by day, last month 45 million user visited Twitter. Most of the international celebrities, film stars, rock stars, individuals, businesses, communities etc have a Twitter account . Enterprises use Yammer which connects you to a specific pool of community.

e. Social Networking: Facebook, LinkedIn, Orkut are three powerful examples in this space. Some organizations scan candidates based on their LinkedIn profile and peer recommendations. These sites also promote collaboration by allowing users to create Groups and Communities.

f. RSS Feeds/Aggregator: Information from many sources is collaborated using popular aggregation services like FeedBurner. It converts your data into XML and generates a feed for your website/web-application. Other /applications can subscribe to these feeds using a RSS Reader software, which is mostly plugged-in into all modern browsers.

g. Mash-Ups: A popular mash-up service is iGoogle and PageFlakes. These sites consume web services and use the power of AJAX to make user experience more seamless and less obstructive. There are little context switches as users get to see everything in one window, a typical iGoogle page can have the Weather report, Email Inbox view, Stock ticker, Digital, News & headlines, Feeds from other websites, Game widgets etc. An icing to the cake is that these services are completely personalized per user.

h. Blogs/Wikis: Popular services like Blogger, WordPress allows users to create, maintain and promote their own blogsites. Non-techie users can create blogsites in a flash and start publishing their posts. Wikipedia allows user to manage information on specific topics.

i. Social Bookmarking: Popular social bookmarking sites like Delicious, NewsGator etc manage user bookmarks and promote sharing and collaboration.

j. Maps & Directions: Google Maps is the best example, users can get directions, exact locations, distance etc all via Satellite imagery.

k. Online Shopping, E-Commerce Applications: Most popular in this category are Amazon, e-Bay etc. They track user purchases and manage user preferences too. Online Air ticket booking systems, Railway reservation systems, Payment gateways like PayPal etc are all examples of the Web 2.0.

The applications mentioned above have gradually changed the face of the Internet and how we consume services. All the applications mentioned above are examples of Rich Internet Applications and leverage Web 2.0.

We are gradually moving into Cloud Computing with Google Chrome O/S, Microsoft Azure etc. That will be a space to watch out for. It will be called as Web 3.0. May be i ll talk about Web 3.0 in some other post.

Friday, October 16, 2009

InfoPath 2007 form and Nintex workflows 2007 - Part 1

Integrating InfoPath 2007 form and Nintex workflows 2007 - Part 1 covers how InfoPath forms interact with Nintex workflow web services.

InfoPath 2007 form and Nintex workflows 2007 - Part 2 covers on how to deploy browser enabled InfoPath forms as Content Types in your SharePoint List/Library.

There are two important Nintex workflow web services which integrates InfoPath form with Nintex workflows, they are:
a. GetRunningWorkflowTasksForCurrentUser(string fileUrl)
b. ProcessTaskResponse(string comments, Outcome outcome, int spTaskId)

a. GetRunningWorkflowTasksForCurrentUser:

This webservice identifies nintex workflow task associated with the currently logged in user for a given List Item which the nintex workflow is bound.

It takes fileUrl as an input String parameter. fileUrl is the server relative url of the list item on which the nintex workflow is currently running.

This webservice helps you retrieve various data fields like SharePointTaskId, HumanWorkflowID, WorkflowName, Comments, WorkflowName, WorkflowInstanceId, TaskName, TaskType etc...

We will see the importance of the same in the Implementation Scenario section of this post.

b. ProcessTaskResponse:

As the name suggests, this web service completes the workflow tasks on behalf of the user.It does the job of completing tasks of the type: Approved, Rejected and Continue. You can imagine an Approval/Review task form. Input parameter comments accept Approvers/Reviewers multi-line comments in the form of a string, outcome is generally of the following pre-defined types either Approved or Rejected for the Approver or else Continue for the Reviewer and lastly spTaskId accepts the SharePointTaskId retrieved by querying the GetRunningWorkflowTasksForCurrentUser web service.

Implementation Scenario:

a. Design an InfoPath form: User fills an InfoPath Expense Report form as shown in Figure 1.1.

Sample Expense Report Infopath Form

Figure 1.1















































b. Submit Data Connection: The form has one Submit data connection which submits all the details of this form to a SharePoint document library, snapshots below show how to create a submit data connection in InfoPath:

i. Go to Tools -> Data Connections -> Click on the "Add " button and you will see the wizard shown below: Choose "Submit data" option and click on the "Next" button





















ii. Choose "To a document library on a SharePoint site" option and click on the "Next" button. Select to a document library option





















iii. Enter your Document library URL, File name (must be a unique file name) and Check mark "Allow overwrite if file exists" option and click on the "Next" button






























c. Receive Data Connections: The InfoPath form must compulsorily have two receive data connections that make calls to the Nintex web services namely:

GetRunningWorkflowTasksForCurrentUser and ProcessTaskResponse respectively. You may have other receive data connections in your InfoPath form, for eg: I may have another receive data connection to receive data from a SharePoint List/Library and show it as a dropdown in my InfoPath form.

Snapshots below show us how to create a Receive Data Connection of the type Web service.

i. Go to Tools -> Data Connections -> Click on the "Add " button and you will see the wizard shown below: Choose the "Receive data" option and click on the "Next" button





























ii. Choose the "Web service" option





























iii. Enter the correct URL as mentioned here, URL for root level site collection should be: http://nintex/_vti_bin/nintexworkflow/workflow.asmx?WSDL
 
for eg URL for a site collection with /sites as managed path should be: http://nintex/sites/sitecollectionname/_vti_bin/nintexworkflow/workflow.asmx?WSDL

If your site collection has also a sub site, then your URL should be http://nintex/sites/sitecollectionname/subsitename/_vti_bin/nintexworkflow/workflow.asmx?WSDL





























iv. Select the web service "GetRunningWorkflowTasksForCurrentUser and click on the "Next" button





























v. Click on the "Next" button





























vi. Click on the "Next" button (let the check box remain unchecked)





























vii. Uncheck the check box option " Automatically receive data when the form is opened"





























Similarly make a web service receive data connection for ProcessTaskResponse nintex web service as well.

d. InfoPath Form Options: We need to set the InfoPath form load options correctly. We need to configure Rules and Actions to ensure two different Views are shown for the Requestor and Approver. We also create a string field namely RequestStatus in InfoPath form, this field displays the Current Status of the Request in the read-only mode in the InfoPath form, this field is updated by our Nintex workflow to set the correct Request Status as per the flow of the workflow.

We also need to get the Task information for the current user who opens up the InfoPath form. Here is where our InfoPath webservice: GetRunningWorkflowTasksForCurrentUser comes into picture.

To set Form Options go to: Tools -> Form Options -> Rules -> Add a new Rule





































i. First we check whether the FileUrl is not blank condition, we need to create a string data source field in our InfoPath form for eg: FileUrl which gets updated by the Nintex workflow using the workflow activity "Set Item Value". Our nintex workflow sets the FileUrl to the current server relative url for the current item on which the workflow is running.

ii. We create a new Rule i.e Load Workflow Information, here we check whether FileUrl (data source field) is not blank for the Rule Condition to execute, see snapshot below
























ii. We then assign the value of FileUrl (local data field generated by the Nintex workflow) to, GetRunningWorkflowTasksForCurrentUser web service input parameter: fileUrl and then query the web service using the action "Query using a data connection" in InfoPath.

iv. This gets all the task related information for the current InfoPath form item on which the nintex workflow has been attached like SharePointTaskId, HumanWorkflowID, WorkflowName, Comments, WorkflowName, WorkflowInstanceId, TaskName, TaskType (i.e. Approval, Review, Collect Data) etc. We need the SharePointTaskId, as it will be used by the ProcessTaskResponse webservice. We also need to check whether task has been created for the user who is currently opening up the InfoPath form.

e. InfoPath Views: The InfoPath form is designed to handle multiple Form Views within the same form. This helps us seperate our Requestor forms and Approver forms.

Without much effort I can create two different Views one for the Requestor and another one for the Approver and depending on the workflow needs for a Reviewer too.

Hence, Views addresses the Role management aspect of a Business Process workflow application.

In order to create an InfoPath View -> Go to Design Tasks Pane on the right -> Views -> Add a New view

You can even copy and paste table/structure from the existing view and later change it as per your requirements.

NOTE: This new View will always refer to the same underlying XML schema/data source, InfoPath just creates a new XSLT per view and not the XML schema/data source.

f. Approvers View:

i. By now we assume that the above InfoPath Expense Report form has been duly filled in by the requestor and submitted for Approval. The workfllow has already started and it has created and updated the FileUrl (local field of the published InfoPath form).

ii. The workflow has also created a task for the Approver in the Workflow Tasks list. He has also received an email with the Item URL asking him to take some action on the request.

iii. So when Approver clicks on the Item URL sent to him via notification email, an InfoPath form opens up. Remember we have to setup predefined conditions on Form Load to Switch Views as per the Task Type and other conditions, see snapshot for Rules and Conditions on form load:































iv. The Approver gets to see the "Approvers View" after form loads and the above rules execute properly, see snapshot






The InfoPath Approval Task form above has a multi-line Comments field, Approve, Reject and Cancel buttons respectively.

g. Process Task Response:

i. The Approver fills in his comments and clicks of the "Approve" button, it is like completing the task assigned to him. But how does Nintex know of it? Here is where Nintex's second web service ProcessTaskResponse. plays a role in completing the task on behalf of the Approver.

ii. We need to configure some Rules and Actions on click of the Approve and Reject buttons, see snapshot below:

For Approve button:

























For Reject button:


























Here we set the ProcessTaskResponse webservice input parameters as follows:

1. spTaskId - SharePointTaskId (returned by the former webservice)

2. outcome - Approved (if approved) or Rejected (if Rejected) (you can have either Approved, Rejected, Continue as outcome)

3. comments - Approver Comments multi-line text field

Then finally we execute the Process Task Response using the InfoPath action "Query using a data connection"

In this way using the two Nintex Web services, we have succeeded in integrating InfoPath form with our Nintex workflow.


Important Information:
Submitted, RequestStatus and FileUrl are fields in the InfoPath form.

a. Submitted is an InfoPath form field and is set to false by default, then as the user clicks on Submit button, we set it to true and use it as a condition in the Form Load options. We configure Nintex workflow's "Wait Until" activity, as we do not want the workflow to start until Submitted value is True.

b. RequestStatus can be set either from Code Behind or Nintex Workflow’s Set Field Value activity.

c. FileUrl needs to be set in the Nintex workflow’s Set Field Value activity as: Current Item’s Server Relative Url.

This will be used as an Input parameter for the GetRunningWorkflowTasksForCurrentUser webservice. It fetches the task information like SharePointTaskId and TaskType for the current user who is trying to open up the InfoPath form. The same SharePoint TaskId will be used to complete his task, using the Process Task Response webservice.

We use it to determine the type of user and task assigned to him and switch Views respectively.

Part 2 covers the correct way of deploying InfoPath forms as Content Types and how to associate them to a particular list/library in SharePoint.

Feel free to share your comments and ask me in case of any doubts.

You can also follow me on Twitter: http://twitter.com/Mehul_Bhuva

I also blog my SharePoint Insights http://www.sharepointinsights.com/