Sharepoint 2013 Custom Workflow Activity SingleTask with Custom Content Type

In this post I’ll talk about how to develop a custom Workflow Activity that creates a SingleTask, with a custom Content Type,  collect data from user and update the target list item with that data.

This post is a sequence from (https://raquelalineblog.wordpress.com/2013/05/11/sharepoint-2013-workflow-custom-declarative-activity/), where I explain in more detail the steps to create a custom Workflow Activity.

I started creating a SharePoint 2013 Empty Project, deployed as a sandbox solution.

I added a new item of type “Content Type”:

CT1

Then I followed the wizard to configure my new Content Type, selected to inherit from item:

CT2

Defined my new content type columns:

CT3

And the basic settings:

CT4

Then I added a new item to my project, of type “Workflow Custom Activity”, and added the actions to have the logic I needed:

CT5

The first actions in my Activity are to get the username of the current’s item author. I used that username in my SingleTask action, in the “Assigned to” field.

CT51

After that I started configuring my Single Task action.

Since I wanted to use a custom Content Type, I started to get my content’s type id. I got that from my content’s type elements.xml file:

CT6

Then I configured my Single Task as in the next picture:

CT7

In the next actions I did the logic to get the value of the Category field from my Workfflow Single Task, and add that field’s  value to the field Category in my target workflow item.

The fisrt step was to get the TaskListId:

CT8

Next I got the Task Item from the Task List, using the taskId, returned in my Single Task action:

CT81

Then I got the value of Category field from the TaskItem:

CT82

And finally I updated my Workflow target list item with that value:

CT83

I created a SharePoint Designer Workflow that calls my new Activity:

CT9

Run my Workflow, and saw my task with my new Content Type (I had to configure my Task List to support this Content Type, in List Settings. This is possible to be done automatically by code):

CT10

Completed my Workflow:

CT11

And saw my Item with the value collected from my task:

CT12

Advertisements

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: