Passed VCP 510 (VMWare Certified Professional)

I recently passed the VCP 510 exam renewing my VCP again before the deadline of February 28th 2012. If I wouldnt have taken the exam before this date I would have had to enroll in the week long training class prior to taking the exam.

The exam was very much like what I have been used to as far as the previous VMWare VCP exams have been, it did seem like there were more select multiple answer type questions than usual.

Here is a great study site that currently has 927 test questions posted, I can say that these questions are right inline with what you can expect to see on the test. If you can get comfortable with these test questions you will surely pass the test with no issues.

Check out the test questions here


SharePoint 2010 101 Code Samples

Microsoft has released 101 code samples for Sharepoint 2010. The samples include HTML 5, AJAX, JQuery, WCF, REST and a lot more.

Check them out Here

Some of the projects include...

Each code sample is part of the SharePoint 2010 101 code samples project. These samples are provided so that you can incorporate them directly in your code. Each code sample consists of a standalone project created in Microsoft Visual Studio 2010


SoftArtisans OfficeWriter - Sharepoint 2010 - Word 2010

I recently had the opportunity to check out SoftArtisans OfficeWriter product. The OfficeWriter product exposes an API that allows information from custom ASP.NET applications to be consumed and used to dynamically and programmatically build Microsoft Word documents and Microsoft Excel spreadsheets.

The OfficeWriter API is a .NET library that allows you to read, manipulate and generate Microsoft Word and Microsoft Excel documents from your own applications. The OfficeWriter product can integrate with Sharepoint 2010 allowing you to export Sharepoint list data into Microsoft Word and Excel documents.

SoftArtisans provides easy to understand sample code, videos and pre-built Sharepoint solutions that make getting started with the product very trivial.

For this tutorial I'll demonstrate deploying, configuring and testing Word Export Plus in a Sharepoint 2010 environment. Word Export Plus is a SharePoint solution that demonstrates the usage of the OfficeWriter API in SharePoint 2010. This solution adds a new context menu (custom action) button to list items, allowing you to export the list data to a pre-formatted Word template that can be designed yourself in Word, or automatically generated by Word Export Plus.

Requirements for this tutorial

  1. SoftArtisans OfficeWriter -  Installed and properly licensed, download the trial from Here
  2. SoftArtisans Word Export Plus - Download the Sharepoint solution installer from Here
  3. Sharepoint 2010  - A site in place that will be used to test the Sharepoint integration features
  4. Microsoft Word 2010 - Installed on the Sharepoint 2010 server


Launch the WordExportPlus.msi executable, this will install the Sharepoint solution into the Sharepoint Farm.

After the Sharepoint solution has been installed it can be deployed

Open Sharepoint Central Administration
Navigate to System Settings |  Farm Management  | Manage Farm Solutions
Select Word Export Plus.wsp
Select Deploy Solution
Specify a deployment time
Select OK

After the solution has been deployed it can be enabled through the site features on the site where the tool is going to be used.

After Word Export Plus has been activated I'll configure it for use.

First I'll create a contacts list that will be the data source for my exports, select Site Actions | View All Site Content | Create and select Contacts

I'll name the list People and select OK.

After the list is created I'll create a couple of test contacts in the list.

Next I'll configure Word Export Plus by selecting Site Actions | Site Settings | OfficeWriter Solution: Word Export Plus

First I'll choose the list that I just created (People) in the Sharepoint List dialog, in the Word Template dialog select Create a new template file. In the Template File Location select the Shared Documents library of the current site. Enter a name for the Template File (Word Template). Enter a name for the Action (Word)

This completes the configuration, 

select Create New Action

To test the new custom action browse to the People list created previously, from one of the contacts select the dropdown next to the last name column and select the action name created previously (Word)

A dialog will open asking if I would like to open or save the WordWriter.Doc file, select Save and after the file is downloaded select Open

This is how the auto-generated template will render the Sharepoint list data, I could have created my own Word template and selected that during the configuration steps. This provides a flexible solution to allow users to get the list data out quickly and formatted nicely into Microsoft Word.


InfoPath 2010 - Sharepoint 2010 Custom Workflow Part 3

Add Custom Code

Next I'll add some custom code to define the logic for the workflow by expanding the InfoPathWorkflow folder and double clicking the InfoPathWorkflow.cs class. This will bring up the design workflow design view. In the design view click the whileActivity1 red exclamation | Choose the property 'Condition' is not set option. 

In the properties window select from the Condition property dropdown: Code Condition

Next expand the Condition property and type into the child Condition property: notDone and press enter

The logic in the code will allow the workflow to run until our condition is met and we change a variable to indicate the workflow is complete.

First I'll create a method to indicate the workflow is not complete. Right click on the workflow design surface and select View Code. Find the auto-generated notDone method and replace the code with the following code snippet.

bool done = default(bool);
private void notDone(object sender, ConditionalEventArgs e)
     e.Result = !done;

The while activity looks at the e.Result value to determine if the loop will continue or not. The onWorkflowItemChanged event will await the event that the workflows list item has changed ( is the site name provided? ) when that happens the after event (invoked) of the onWorkflowItemChanged activity will fire providing the opportunity to change the done variable to true. The while loop will then run the notDone method to check the e.Result which will always return the opposite of done (!done) the while loop will exit when done is set to true.

Double click the onWorkflowItemChanged1 shape in the designer view to generate the onWorkflowChanged1_Invoked method. Replace the auto-generated method with the following code snippet

private void onWorkflowItemChanged1_Invoked(object sender, ExternalDataEventArgs e)

private void isSiteNameProvided()
     if(!string.IsNullOrEmpty(workflowProperties.Item["SiteName"] as string))

Double click on the onWorkflowActivated1 shape to generate the onWorkflowActivated1_Invoked method. Replace the auto-generated method with the following code snippet.

private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)

From the workflow designer surface click on the onWorkflowItemChanged1 red exclamation and choose the activity 'onWorkflowItemChanged1' does not have a Correlation Token property set option

Note: A Correlation Token is just an unique identifier for the workflow, it's used to keep all of the individual workflow activities together. 

From the properties window select the CorrelationToken property dropdown: workflowToken.

Back to the design surface and choose the codeActivity1 red exclamation, select the property 'ExecuteCode' is not set. Double click the codeActivity1 shape to generate the ExecuteCode method

Add Exception Handling to the Workflow

Next I'll add some error handling so if an exception occurs we'll write the text of the exception to the History List and set the column status to error logged and allow the workflow to exit and complete.

Next ensure the toolbox is open and the Windows Workflow V3 node is expanded. Drag and drop a FaultHandler activity onto the Drop FaultHandlerActivity Here text. 

In the Workflow Exceptions window select the faultHandlerActivity1 red exclamation, choose the Property 'FaultType' is not set or its value cannot be resolved to an actual type option. 

In the properties window select the FaultType property ellipses, in the Browse and Select a .NET type window Select Referenced Assemblies | mscorlib on the Type tab. Select the System type, locate Exception in the type name column (scroll the right pane down) Select the Exception type name (System.Exception) and select OK.

In the Visual Studio Toolbox expand the Sharepoint Workflow node, Drag and drop a LogToHistoryListActivity activity into the Drop Activities Here text. Drag and drop a SetState activity on the line below the logToHistoryListActivity1 shape

Next I'll configure the Log to History List Activity to write the exception details to the Workflow History List and the Set State Activity to end the Workflow with a custom status called Error Logged. 

On the InfoPathWorkflow design surface right click the logToHistoryListActivity1 shape and select the properties option. Select the HistoryDescription property and click the ellipsis. 

In the Bind History Description dialog expand faultHandlersActivity1 | faultHandlerActivity1 | Fault | Message and select OK

In the properties window select the HistoryOutcome property and click the ellipsis. In the bind History Outcome to an activity dialog expand faultHandlersActivity1 | faultHandlerActivity1 | Fault - Select the StackTrace option and select OK

In the Visual Studio Solution Explorer double click the elements.xml file

Replace the metadata node and its contents with the following code 

         <StatusColumnValue>Error Logged</StatusColumnValue>

Back to the design surface for the Infopath workflow, double click the setState1 Activity, replace the setState1_MethodInvoking with the following code

private void setState1_MethodInvoking(object sender, EventArgs e)
            setState1.State = (int)SPWorkflowStatus.Max;

This code will set the workflow state to the custom StatusColumnValue defined in the elements.xml file

Back to the workflow design surface, select the red exclamation next to setState1 activity

Choose the Activity setState1 does not have CorrelationToken property set, select the correlationtoken property dropdow: workflowToken

Now when an exception occurs it will be handled and logged as shown below

Create a New Site Collection and Add Quicklaunch Link to Site

The next part of this tutorial will involve programmatically creating a new site collection if the site name condition is met on the list we are attaching this custom workflow to. 

Right click on the InfoPath workflow design surface and select view code. In the top area of the InfoPathWorkflow.cs file add the following import directive

using Microsoft.SharePoint.Navigation;

Next replace the method codeActivity1_ExecuteCode with the following code.

private void codeActivity1_ExecuteCode(object sender, EventArgs e)
            //Get the Site Name
            string SiteName =
            // Get the system token, instantiate new site and web objects
            // in order to have permissions to create the new Site Collection 

            SPUserToken _sysToken = default(SPUserToken);
                using (SPSite site = new SPSite(workflowProperties.Site.Url))
                    _sysToken = site.SystemAccount.UserToken;

            using (SPSite siteCollection = new SPSite(workflowProperties.Site.Url, _sysToken))
                using (SPWeb web = siteCollection.OpenWeb(workflowProperties.Web.ServerRelativeUrl))
                    //Gather user information
                    SPUser user = web.SiteAdministrators[0];
                    string adminLogin = getLoginName(user);
                    string adminEmail = user.Email;
                    string adminDisplayName = user.Name;

                    SPSite newSiteCollection = default(SPSite);

                      () =>
                         //Set the new site collection properties
                          newSiteCollection =
                            "/sites/" + SiteName,  // Url
                            "Site Created by Submitting InfoPath Form",
                            1033,  // locale identifier - US English
                            "SGS#0",  // Basic Group Work Site Template

                    if (default(SPSite) != newSiteCollection)
                        // Add Site Collection Administrators

                        string newSiteCollectionUrl =

                        // Add Site collection link to Quick Launch
                        SPNavigationNode projectSiteNode =
                          new SPNavigationNode(SiteName, newSiteCollectionUrl, true);

                        // Create or retrieve the Site Collections node
                        SPNavigationNode siteCollectionsNode =
                          ensureHeadingNode("Site Collections", web.Navigation.QuickLaunch);
        //Extract a readable username
        private string getLoginName(SPUser user)
            string loginName = default(string);

            int pipePosition = user.LoginName.IndexOf("|");

            if (0 >= pipePosition)
                loginName = user.LoginName.Substring(pipePosition + 1);
                loginName = user.LoginName;

            return loginName;

        // Add the Site Collection Administrators from
        // the current Site Collection to the new Site Collection

        private static void addSiteCollectionAdministrators(
          SPUserCollection existingSiteAdmins, SPUserCollection newSiteAdmins)
            // Add the Workflow's Site Collection Administrators
            // to the new Site Collection
            foreach (SPUser admin in existingSiteAdmins)
                  admin.LoginName, admin.Email, admin.Name, admin.Notes);

        // Add a custom SPQuickLaunchHeading NavNode
        // if it doesn't already exist
        private static SPNavigationNode ensureHeadingNode(
          string nodeHeading, SPNavigationNodeCollection quickLaunch)
            // Get the first NavNode in the Web's Quick Launch
            SPNavigationNode projectSitesNode = quickLaunch[0];

            if (nodeHeading != projectSitesNode.Title)
                // Quick Launch Heading NavNode called nodeHeading
                // linked to the Web's Home Page (empty string)
                projectSitesNode =
                  new SPNavigationNode(nodeHeading, string.Empty);
            return projectSitesNode;

Deploy and Test

The last part of this tutorial will involve deploying the Visual Studio Solution and testing.
From Visual Studio right click on the project name and select Deploy, ensure there are no errors in the build and wait for the process to complete.

Next, well visit the site that we deployed the workflow to, in my case it is at  http://w2k8r2_2010dev/sites/apps/

Select the list that we created in step 1 - Issues

From the Ribbon select the List tab and Click the Workflow Settings dropdown | Add Workflow

Select the InfoPath Workflow from the available Workflows, enter a name for the workflow and select the Start this workflow when a new item is created checkbox

From the Issues List create a new item

Note: If your URL has an underscore (_) in it you will receive the following message: The form cannot be displayed in the browser because the use of session cookies has been disabled in the current browser settings

In my case and can simply change the machine name in the URL with Localhost after adding an alternate access mapping and everything works.

Next Add the new item - MyIssue, I'll intentionally leave the SiteName field blank to demonstrate the workflow functionality

Immediately after we submit the new item the status will change to Starting

Then the workflow status will quickly change to In Progress

The workflow status will remain at In Progress until we edit the item we submitted and add a SiteName

Note: If a SiteName is added initially the workflow will complete quickly on its own

Next I'll edit the entry and add the SiteName (MyIssues Site) and in a minute or two I will see the Quicklaunch area under Site Collections will be updated with the new SiteName. If this is the first entry then the Site Collections heading will be added and a link to the new site will be listed below.

This completes this tutorial. If you would like to download the Visual Studio Solution Click Here