Application pages

I’ve decided to write this blog articles series when I’ve realized how much time I’ve spent understanding the application pages and all related topics. These articles have been written from a specific problem point of view. I have to write a custom workflow for the custom list. And there’s no way that I can do it with SharePoint designer. I have to use Visual Studio to create all from scratch.

The application page itself is nothing fancy. You will find hundreds of articles over the Internet, but I can’t find information on how to link them with other possible options of SharePoint server. Their power you will be able to see with other modules of SharePoint.

Let’s make an assumption, that you run SharePoint standard or foundation. There’s no forms server for your InfoPath forms, which are very useful from my point of view… And you have to develop a workflow for your custom list. Some information is stored in other parts of your environment (SQL Server, Web service, etc) or for some reason you have to use controls from another vendor, like Telerik. So you have to use code behind and it means that you need an application page. Of course, there’s another possibility, but for my case it was not acceptable. So what can I do?

1. I need custom list. That list will use custom forms for “NEW” and “EDIT” form.

2. The forms will use some code behind action to be sure that information entered by the user is valid and some of them are stored in ERP system.

3. I will create a custom workflow. But I’m not going to use workflow which use directly task list. We have cases that some crazy users close assigned task, but in fact the task itself wasn’t accomplished. So I’m going to implement function which will check the list to be sure that there’s required data. And without that, the workflow and task will be stick to the user until he fill necessary information.

So let’s start! We create an empty SharePoint 2010 project. As we need need custom type to keep there’s all necessary information, we have to add content type to the project. For my case I need the following fields:

– invoice number

– invoice date

– invoice amount

– supplier

– purchase order

And my custom type looks like this:

image

The next step show us power of VSTO SharePoint tools Uśmiech. We add next item to our solution: “List Definition From Content type”. We select content type created in previous step and now VSTO make magic…

image

We get almost ready to use List Schema! We just need to fill information about our fields and the list is ready to deploy.

image

Wasn’t fast Uśmiech ?

When we deploy our solution we will see our custom list. There’s just one thing to do. When we press “New Item” on our list, we’ll see standard SharePoint form. We have to do two things to use our own forms. First, we have to add a new item to our solution: “Application page”, and to avoid a mess in the Layouts folder we should create own folder for our application page.

When we do that we have to modify the Schema of our list. We have to change Inherits to FALSE and add “FormUrls” tags with path to our application page. And that’s all. When you deploy the solution and press “New Item” you will get our empty application page.

image

What can we do next I will show you in the next post.