1. Open the VS 2008 and create new web Page. e.g. “WebForm1.aspx”
2. Design the page by adding the web controls in it.
3. Replace the Page Directive

4. Assign the strong key name to the project
5. Build the project. Deploy the DLL in the GAC and place the ASPX page in the Layout folder [12 Hive]
Create Visual Studio Workflow Task
1. Open the VS and create the new project of type Workflow
2. Take the workflow template “SharePoint 2007 Sequential Workflow” OR “SharePoint 2007 State Machine Workflow” as per the requirement
3. In this example we will create workflow using State Machine.
4. Click on the Workflow.cs File
5. In the Design Page right click and “Add State” stateActivity1
6. “Add State Initialization” as first activity. Drop “Create Task with Content Type” state activity.
7. Assign Task Id, Task Property, Correlation Token
Double click on the activity to generate the event handler.
private void createTaskWithContentType1_MethodInvoking(object sender, EventArgs e)
{
try
{
using (SPWeb currentWeb = workflowProperties.Item.Web)
{
this. createTaskWithContentType1_TaskId = Guid.NewGuid();
this. createTaskWithContentType1_ContentTypeId =
"0x010801004D7BB01867D748ba8BE646B432F7ECEF";
SPList currentTaskList =
currentWeb.Lists["TASK LIST NAME"];
VerifyModifyTaskList(currentTaskList, this.
createTaskWithContentType1_ContentTypeId);
createTaskWithContentType1_TaskProperties.Title = "New
Task Created";
createTaskWithContentType1_TaskProperties.AssignedTo =””
}
}
catch (Exception ex)
{
}
}
0x010801004D7BB01867D748ba8BE646B432F7ECEF This is the Content Type ID that is assigned to the task. This content type id refers to the ASPX page created in the previous step that is deployed in the layouts.
//This fucntion is used for verifying task creation process during approval process
public void VerifyModifyTaskList(SPList taskList, string contentType)
{
try
{
SPContentTypeId contentTypeId = new SPContentTypeId(contentType);
taskList.ContentTypesEnabled = true;
SPContentTypeId matchContentTypeId = taskList.ContentTypes.BestMatch(contentTypeId);
if (matchContentTypeId.Parent.CompareTo(contentTypeId) != 0)
{
SPContentType ct = taskList.ParentWeb.AvailableContentTypes[contentTypeId];
taskList.ContentTypes.Add(ct);
taskList.Update();
}
}
catch (Exception ex)
{
}
}
8. Create New Content Type XML
a. Add new XML File in the workflow project e.g. Test.XML
b. Insert following XML

c. Assign New Content Type ID
0x01080100 Content type Id for Workflow, this value never change
4D7BB01867D748ba8BE646B432F7ECEF Any Random GUID
d. Replace the newly created content type Id in the workflow “createTaskWithContentType1_ContentTypeId”
e. Rebuild the project and deploy the workflow DLL in the GAC
f. Recycle the Application Pool for web application after DLL GAC deployment
g. Create new Feature and place “feature.xml”, “workflow.xml and Test.xml” file in it.
h. Install and activate the feature.
i. Check the newly created content type. It will come in the site Content Type Section.
j. Attach the workflow to any List\ Library.
k. Once you click on the task created using this workflow it will open OUR custom ASPX page.
l. You can redesign the complete workflow by adding other activities.
No comments:
Post a Comment