InfoPath to FoSL (MS Access)? Sounds ancient already..

One of the biggest questions I wanted answered during last week’s SharePoint Conference in Las Vegas was the future direction of forms in SharePoint. What will replace InfoPath and how do we start this huge task of migrating and converting forms and customized list forms that are embedded in our solutions provided to business. Unfortunately, Microsoft did not give a clear path on the subject but to summarize there will a couple of tools by 2015 that will help customize list forms and provide forms to our users. Here are the two routes currently discussed:

1) FOSS, or Forms on Spreadsheets. These are simply spreadsheet based forms and surveys and only hold value for those types of applications. You can’t use the form to submit to a list etc so its viability and overall usage will be minimal. They also included information on basic Word fill-able forms and auto-filling data based on the document metadata.

2) The second, FOSL or Forms on SharePoint Lists. There will be a new button on the ribbon next to the Customize in InfoPath button. This allows for basic form design in browser. It is nice that you don’t have to launch a new application to customize a form. However, due to this lightweight in-browser design, it looks like we will sacrifice advanced data connections and web service calls. Microsoft did mention that they plan on adding this into FOSL. FOSL will include basic CRUD operations within the tool bar. All of the form design is being made possible by MS Access.

Forms On SharePoint List (FOSL Sample) Non Modal No Client Needed

It seems Microsoft is gearing itself to provide various Types of Forms for different user scenarios.
Some Information on the Roadmap and differences in Form Types:

So in all this uncertainty Microsoft wants our feedback about the forms roadmap! Go here to submit your opinion officeforms.uservoice.com

In the conference they even stated “InfoPath is an amazing product , We don’t have a full replacement”, so we can guide them forward.

The Future of InfoPath is still unclear , especially in advanced Form designs with web service calls and custom code behind them. Perhaps Microsoft will never be able to provide this to us on FOSL , so third party tools like Nintex and K2 will smile.

Will Microsoft Provide migration tools for InfoPath? “We don’t know yet, we are evaluating various ways to aid in migration. Third parties may provide tools, or even support running InfoPath forms into the future”

In conclusion, for now there is no clear direction on how we will move our existing forms into the new fragmented model. But, InfoPath will be support until 2023 so let’s not worry too much about this, give it a few years to mature and then plan for the jump.

And then Microsoft; Code names being what they are, maybe FoSL isn’t the best one to use to launch a new development feature to replace a retiring tool?!?

Saving Multiple lines in Infopath Form to a SharePoint 2010 list Column

When you create lines in InfoPath Forms it allocates 255 Characters and creates a Single line of Text column in SharePoint when Uploaded and Published via InfoPath Form Services.

We recently had this in a Online Feedback form that had to cater for more lines in the feedback Message.

The following blog post will explain what we had to do to update the solution to the this working as a multiline.

When you look at the old List in the Site you’ll see the old message column updated as the sample below before the change cutting off the text after 255 characters

Here is the view of the Content Type and Columns showing the published Field Types as Single line of text. Unfortunately because of it being Created via InfoPath Form Services, we cannot just update the Column here and update it across the site.

Create a new Site Column called Similar to your original Column as below sample and give it a multiline type.

Once created add this to the Content Type as an extra Column.

Select Add to All Content Types to push it down to the site.

Now you’ll see the field as Multiline below along with the other Form Columns.

Now open the InfoPath form and go to Form Options. We will now relink the Field to the new Column

When Publishing the system will also allow you to associate a field to a SharePoint Column. Check if it is correctly setup or correct here during publishing.

Once published and updated via Update in InfoPath Forms Services go to the site and form.

Open the new Form and add a lot of text into the Message and hit save/submit. The content will now be stored into the new associated column in the backend list in SharePoint.

Here you go the content is updates as multiline

Submitting a “Contact Us” InfoPath form into a SharePoint List Anonymously and starting a workflow in SharePoint 2010

Recently we have been involved in quite a few public websites with Contact Us forms on them.

a Customer would then generally fill in the form and submit this . In the backend the item had to be stored and a mail

sent off to recipients dealing with the request.

SharePoint offers wonderful components to be used out of the box but some obstacles around Anonymous sites and SystemAccount exists.

The Purpose of this article is to explain what is needed to get this solution working.

We used a InfoPath form with a Captcha component http://distinctcaptcha.codeplex.com/ in it that worked really well.

To submit the Information into the SharePoint backend library does require you to elevate your privileges to SystemAccount else your site will not allow submission of the item into the backend SharePoint List.

Lastly we had to start a simple SharePoint Designer workflow that runs on ItemAdded that sends notifications to a specific SharePoint Group of Recipients. Here an event receiver had to be created and added to the list to allow the start of a workflow by systemAdmin on ItemAdded.

Below are the steps in more detail for the full solution:

Create your Form in InfoPath and Go to the Developer Tab to hook up the C# Code to elevate your account to SystemAdmin on Submit.

Choose Template Code Language as C# and provide the path for the project

Create your Submit button and hook it up to C# Click Event

Go to Visual Studio and create a Project and Form to keep your code and action the saving on Sbmit. It elevates the account and saves to the list.

Note that we also created a View that displays after successful submission that is called ThankYou. Here we tell the customer that the form was successfully submitted and expected response time.

Here is the extract of the Code to Elevate the Account To SystemAdmin ,saved to the library and moves the view to ThankYou


using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using Microsoft.SharePoint;

namespace Contact_Us
{
    public partial class FormCode
    {
        // Member variables are not supported in browser-enabled forms.
        // Instead, write and read these values from the FormState
        // dictionary using code such as the following:
        //
        // private object _memberVariable
        // {
        //     get
        //     {
        //         return FormState["_memberVariable"];
        //     }
        //     set
        //     {
        //         FormState["_memberVariable"] = value;
        //     }
        // }

        // NOTE: The following procedure is required by Microsoft InfoPath.
        // It can be modified using Microsoft InfoPath.
        public void InternalStartup()
        {
            ((ButtonEvent)EventManager.ControlEvents["CTRL10_5"]).Clicked += new ClickedEventHandler(CTRL10_5_Clicked);
        }
        public void CTRL10_5_Clicked(object sender, ClickedEventArgs e)
        {
            // Write your code here.
            XPathNavigator root = MainDataSource.CreateNavigator();
            string xpathValidateResult = root.SelectSingleNode("/my:myFields/my:ValidationResult", NamespaceManager).Value;

            if (this.Errors.Count == 0)
            {
                if (xpathValidateResult == "true")
                {
                    string xpathErrorLine = "/my:myFields/my:ErrorMessage";
                    XPathNavigator errorLine = MainDataSource.CreateNavigator().SelectSingleNode(xpathErrorLine, NamespaceManager);
                    errorLine.SetValue("");
                    this.ViewInfos.SwitchView("ThankYou");

                    //Submit the form
                    SPSecurity.RunWithElevatedPrivileges(delegate() { this.Submit(); });
                }
                else if (xpathValidateResult == "false")
                {
                    //Show error message
                    string xpathErrorLine = "/my:myFields/my:ErrorMessage";
                    XPathNavigator errorLine = MainDataSource.CreateNavigator().SelectSingleNode(xpathErrorLine, NamespaceManager);
                    errorLine.SetValue("Security code incorrect, please try again.");
                }
            }
            else if (this.Errors.Count > 0)
            {
                //Show error message
                string xpathErrorLine = "/my:myFields/my:ErrorMessage";
                XPathNavigator errorLine = MainDataSource.CreateNavigator().SelectSingleNode(xpathErrorLine, NamespaceManager);
                errorLine.SetValue("Please complete all required fields as indicated by an asterisk (*)");
            }
        }

    }
}

Once done Compile and the Publish the InfoPath Form.

You will have to ask your sysadmin to then upload this Form into the Central Administration InfoPath Form Services at

You will then be able to add it in a InfoPath Form Webpart in a .aspx form on your public website that runs anonymously.

If all goes well and your C# Code runs on submit you’ll be able to submit the Contact Us information into the backend list and see that it was modified by SystemAccount

Lastly you’ll have to hook up a SharePoint Designer workflow onto the solution that starts on ItemAdded. Note that because of the SystemAccount that created the List item the workflow will not start since it’s a SharePoint Constraint out of the box.

What you need to do is run a simple EventReceiver update on the list via powershell to get this going.

Let’s show you

So in SharePoint Designer create a workflow on the List that starts on ItemAdded

Setup the email template and detail that you want to save in the email

Now for you to be able to get past the SystamAdmin workflow start constraint,we had to create a Eventreceiver and attach it to a list.

This EventReceiver checks if the Account trying to start a workflow is the systemAccount and then allows it.

Here is the code that youll need to have to create the event receiver

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.Administration;
using System.Collections;

namespace Shoprite.SharePoint
{
	/// <summary>
	/// List Item Events
	/// </summary>
	public class WorkflowAutostartEventReceiver : SPItemEventReceiver
	{
		/// <summary>
		/// Start IsDeclarative AutoStartCreate and AutoStartChanged workflows, if currently running as System Account.
		/// </summary>
		/// <param name="properties">Item event properties.</param>
		/// <param name="itemAdded">True if called from ItemAdded, False otherwise.</param>
		/// <param name="itemUpdated">True if called from ItemUpdated, False otherwise.</param>
		private static void StartWorkflows( SPItemEventProperties properties, bool itemAdded, bool itemUpdated )
		{
			try
			{
				if( properties.CurrentUserId == properties.Web.Site.SystemAccount.ID )
				{
					var workflowManager = properties.Web.Site.WorkflowManager;

					var workflowAssociations = new ArrayList();
					workflowAssociations.AddRange( properties.List.WorkflowAssociations );
					workflowAssociations.AddRange( properties.ListItem.ContentType.WorkflowAssociations );

					foreach( SPWorkflowAssociation workflowAssociation in workflowAssociations )
					{
						if( workflowAssociation.IsDeclarative )
						{
							if( itemAdded && workflowAssociation.AutoStartCreate || itemUpdated && workflowAssociation.AutoStartChange )
							{
								workflowManager.StartWorkflow( properties.ListItem, workflowAssociation, workflowAssociation.AssociationData, true );
							}
						}
					}
				}
			}
			catch( Exception exception )
			{
				var category = new SPDiagnosticsCategory("WorkflowAutostartEventReceiver", TraceSeverity.Unexpected, EventSeverity.Error );
				SPDiagnosticsService.Local.WriteTrace( 0U, category, TraceSeverity.Unexpected, "Error in StartWorkflows : Exception detail " + exception.ToString( ), null );
			}
		}

		/// <summary>
		/// An item was added.
		/// </summary>
		public override void ItemAdded( SPItemEventProperties properties )
		{
			base.ItemAdded( properties );

			StartWorkflows( properties, true, false );
		}

		/// <summary>
		/// An item was updated.
		/// </summary>
		public override void ItemUpdated( SPItemEventProperties properties )
		{
			base.ItemUpdated( properties );

			StartWorkflows( properties, false, true );
		}
	}
}

Once Compiled and deployed to your environment you can then do the last step.

Get your Administrator to run a simple powershell script to attach the above EventReceiver to the specific Contact us List.

Wrap this into Powershell .ps1 File and run.

$webUrl = "http://www.yourpublicsite.com"

$lists =
(
	"/contact-us/Contact Us"
)

$web = Get-SPWeb $webUrl

Write-Host "Attaching EventReceivers"

$lists | ForEach-Object {
	$list = $web.GetList( $_ )
	$list.EventReceivers.Add( "ItemAdded", "Shoprite.SharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0b12b2f19507f6be", "Shoprite.SharePoint.WorkflowAutostartEventReceiver" )
}

That’s it !!!

You will then be able to submit the report and get your workflow to starrt….

And you’ll receive the recipeint email from the ItemAdded Workflo if your’e setup correctly in the SharPoint Group..

Enjoy!

Stats on browser use – Chrome winning

I’m doing some research on stats regarding browser usage in Africa and came across an excellent resource site http://gs.statcounter.com/

When we build Public facing sites on SharePoint or any other platform out there these stats show us on which browsers to focus as we move into Africa without losing focus on what’s the South African usage trend.

There stats are clearly showing Chrome gaining market share.

http://gs.statcounter.com/#browser-ww-monthly-201204-201304

Then look at Africa, clearly showing IE losing market share everywhere…

Except in South Africa.. the landscape is still a Strong IE landscape.. but declining

Use these stats and play around to find out where to focus your compatibility requirements.

Business users should also be made aware of the trends and options available and not just

require compatibility across all browsers since this could limit latest technology inclusion & rollout on your websites.

Creating a new version of a public site using Mount and Dissmount

Ok so before you rebuild a site in Production we had a challenge of replacing a new site with the least amount of time and effort spent.
Very simple but very effective

We did the following:

1) create new site. Build and Test this in QA or on a different URL in Production. (If In QA, remember to backup and restore the Content DB in Production)

2) Once tested run the following PowerShell.

3) Detach Site from Temp Live of QA site

a. Get-SPContentDatabase -WebApplication http://Tempsitename

b. Dismount-SPContentDatabase “NewDatabase”

4) Detach Site from Live site (Now you’ll bring your main site down)

a. Get-SPContentDatabase -WebApplication http://sitename

b. Dismount-SPContentDatabase “OldDatabase”

5) Mount-SPContentDatabase "NewDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename

So moving content from www1 to www in my example now looks like

Change Host header and Web Application in SharePoint 2010

Ok I’ve recently had to create a new version of a public site while the old site was still in use.

I needed to afterwards move the old site to the new site name.

I run on HOST names and a Site collection of a Web Application.

I did some reading but could not find a detailed way to do this.

Mine might be incorrect but it worked for me. This is only the part to move the web application and Host header to a new path.

So in short I wanted to rename/change www2.domain.co.za to www3.domain.co.za

or similar http://www.tempcompany.com to http://www.company.com

It involved 3 steps

1) Alternate Access mapping change

2) Change IIS & rename Bindings

3) Rename Web application

I started off with a new web application created i.e. www2.domain.co.za

It involves 3 steps

1) In Central Admin you do Alternate Access mapping change. Edit Public Url

Simply change the url , in my case www3.domain.co.za

Step 2 , change IIS rename Bindings (Do this on all your front end servers (might be able to do this with a PowerShell command)

Rename Site

Step 3 , rename Web application

Run this script in PowerShell to rename the web application

$a=Get-SPWebApplication | where {$_.Name -match "www2.domain.co.za"}

$a.Name

$a.Name="www3.domain.co.za"

$a.Update()

Open the site and all will now work under www3.domian.co.za

Content Reporting Matrix

We recently did a comparison on Reporting components for AvePoint , OOTB SharePoint, and Control Point.

These are some of the findings of functionality how I understood it and where they overflow. Both products are very good.

We ended up building a case around AvePoint, purely because of us having other modules already along with their good customer service record.

a1

a2

a3