I’ve decided to write this blog articles series when I’ve realized how much time I’ve spent to understand the application pages and all related topics. These articles has been written from specific problem point of view. I have to write custom workflow for 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 articles over Internet, but I can’t find information how to link them with other possible option of SharePoint server. Their power you will be able to see with other modules of SharePoint.
Let’s make 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 workflow for your custom list. Some information are stored in other part of your environment (SQL Server, Web service, etc) or for some reasons you have to use controls from other vendor, like Telerik. So you have to use code behind and it means that you need application page. Of course there’s other 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 user are valid and some of them are stored in ERP system.
3. I will create 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 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 following fields:
– invoice number
– invoice date
– invoice amount
– purchase order
And my custom type looks like this:
The next step show us power of VSTO SharePoint tools . 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…
We get almost ready to use List Schema! We just need to fill information about our fields and the list is ready to deploy.
Wasn’t fast ?
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 new item to our solution: “Application page”, and to avoid mess in Layouts folder we should create own folder for our application page.
When we do that we have to modify 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 solution and press “New Item” you will get our empty application page.
What can we do next I will show you in the next post.