Custom Workflow Actions/Activities


Yesterday I had to implement a custom Action/Activity to satisfy the requirements of a particular scenario at a client engagement. I needed an Action for our SharePoint Designer workflows that could assign a permission level/role to a list item.

I did not canvas the web looking for an existing piece of work to accomplish this for several reasons, but in my travels I also did not notice an activity like this one.

The custom activity is your basic custom class inheriting from Workflow.ComponentModel.Activity, so nothing special here. I implemented 4 overridden static properties of type DependencyProperty to get the execution context, the list and list item IDs, and the person for whom the permissions are being granted.

A unusually convenient built-in behavior of using a Person field is that is provide the login ID of the specified person. This is handy as you need their domain ID to implement the RoleAssignment object you will use to grant the user their permissions.

The basic heart of the implementation is 4 lines of code, plus the addition, or alteration, of a custom .actions file in the /Template/1003/Workflow folder to declare the activity inputs, text displayed, etc. Below is how the activity appears in SharePoint Designer.

grant-permissions-activity

Advertisements

About generation12

I am a SharePoint/.NET consultant in the twin cities.
This entry was posted in Workflow Actions and tagged . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

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