Archive | Workflows RSS for this section

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 (, 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”:


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


Defined my new content type columns:


And the basic settings:


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


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.


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:


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


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:


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


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


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


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


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):


Completed my Workflow:


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



Sharepoint 2013 LookupSPGroupMembers Workflow Activity

I created  a custom workflow activity that writes to history list all users from a specific group.

In this post I will not explain step by step the details to create a custom activity, you can see that in  (

I’ll be focused on the detail to iterate through group members Dynamic Value result.

My Custom Avctivity is:


I’ll explain now the details of the principal activities.

We need a LookupSPGroupMembers activity that will put the result in a local variable GroupMembers, of type DynamicValue:


This DynamicValue is an  array of DynamicValues, so I”ll get the number of returned elements , I need 2 activities for that (GetDynamicValueProperty, and CountDynamicValueItems from the variable properties).



Next, I need to iterate through the variable GroupMembers to get the loginNames:


I log to HistoryList each LoginName:


The result is:


Sharepoint 2013 Workflow Custom Declarative Activity

In SharePoint 2013 it is possible to create custom declarative activities (in Visual Studio 2012), that will be exposed and can be used in SharePoint Designer Workflows. In this way we can extend SPD OOB Workflow Activities.

To create a custom activity, create an Empty SharePoint 2013 project and select the deployment as sandbox solution.

Add a new Item, select Workflow Custom Activity:


Then you will need to create your Workflow Activity actions, use the ToolBox and drag the actions you need.

In my case, I used the “LookupSPPricipal”, that receives a UserLoginName, and will get that user’s information from Sharepoint. The UserLoginName is defined as an input argument to my WF Activity. The output of this action will go to a local variable named “User”.


I used another action “GetDynamicValueProperties” to get the User’s Display Name. This action receives the object “User” and the output goes to  an output argument “DisplayName”


We need to configure the output and input parameters in the file “.actions4”.


After that, I deployed my WF and opened SharepointDesigner. I could see my new Activity:


I created a test Site Workflow that calls my Custom Activity, and logs to history list the output “Display Name”:


I published my WF and run it:


Sharepoint 2013 Develop a Visual Studio 2012 Workflow

In Visual Studio 2012 you can create Sharepoint 2010 WFs or Sharepoint 2013 WFs.

Sharepoint 2013 WFs are declarative WFs, so they don’t have code associated or a dll to deploy to GAC.

In this sample, I  created a VS 2012 WF in a empty Sharepoint 2013 project, deployed as a sandbox solution.

First step is to create the project:


Select deploy as a sandbox solution:


After your project is created, select Add a New Item and choose Workflow:


At this point you can choose between a List or a Site Workflow. Site Workflows, were introduced in Sharepoint 2010, and they run at the Site level.

In this sample I choose to use a List Workflow:


In the next step I selected the Document list, this is the list, where the Workflow will be available:


In the next step I choose to create a new task and history lists:


The last step, is to select the startup type, for your Workflow, it can be manual, On Item Added and On Item Updated.

After this step you can start creating your Workflow:


In the Toolbox, you can see the activities that you can use in your Workflow, you just need to drag them to your WF design.

If you explorer your solution, you can see that you have a feature to create a history list and a task list to your Workflow.

My Workflow starts writing to history list “WFStarted”.

Next I Create the tasks to get the user name that created the current item.

First you need the “LookupSPListItem” activity to get the ListItem properties.

Next “GetDynamicValueProperties” to get the ListItem AuthorID to a WF Variable:


Next you need the “LookupSPUser” to get the User properties for the AuthorId:


And another “GetDynamicValueProperties” to get the LoginName, to a Workflow Variable.


And finally the task that writes to history list the message “WFSample End Author:” + username


The all  Workflow  is:


After deploy the solution, the Workflow will run in Documents list:


Sharepoint 2013 error running Workflows with System Account

When running Workflows with the System Account you will get an error:

RequestorId: 426a583e-b203-d886-b12d-0bd432b567da. Details: System.ApplicationException: HTTP 401 {“Transfer-Encoding”:[“chunked”],”X-SharePointHealthScore”:[“0″],”SPRequestGuid”:[“426a583e-b203-d886-b12d-0bd432b567da”],”request-id”:[“426a583e-b203-d886-b12d-0bd432b567da”],”X-FRAME-OPTIONS”:[“SAMEORIGIN”],”MicrosoftSharePointTeamServices”:[“″],”X-Content-Type-Options”:[“nosniff”],”X-MS-InvokeApp”:[“1; RequireReadOnly”],”Cache-Control”:[“max-age=0, private”],”Date”:[“Thu, 02 May 2013 14:20:40 GMT”],”Server”:[“Microsoft-IIS\/8.0″],”WWW-Authenticate”:[“NTLM”],”X-AspNet-Version”:[“4.0.30319″],”X-Powered-By”:[“ASP.NET”]} {“error”:{“code”:”-2147024891, System.UnauthorizedAccessException”,”message”:{“lang”:”en-US”,”value”:”Access denied. You do not have permission to perform this action or access this resource.”}}} at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor

You have to run the Workflows with an account that isn’t the system account.

Sharepoint 2013 error after install WorkflowManager

After install and configure Workflow Manager, you can get this error:

“The option for the SharePoint 2013 Workflow platform is not available because the workflow service is not configured on the server.”

I solved this, deleting the “Workflow Service Application Proxy” in Central administration, and run again the WF configuration manager wizzard, a first run to remove from farm, and a second run to add to farm. It’ll create this service application proxy again.

Sharepoint 2013 Workflows in a stand-alone instalation

SharePoint 2013 stand-alone instalation instals sql server 2008 express.

In sql 2008 express, the User Profile Service Synchronization doesn’t start:

In this case all my 2013 plataform workflows were canceled with the error:

RequestorId: 55c6990b-c4a6-352c-4a5b-449fc1aecac4. Details: System.ApplicationException: HTTP 401 {“x-ms-diagnostics”:[“3001000;reason=\”There has been an error authenticating the request.\”;category=\”invalid_client\””],”SPRequestGuid”:[“55c6990b-c4a6-352c-4a5b-449fc1aecac4″],”request-id”:[“55c6990b-c4a6-352c-4a5b-449fc1aecac4″],”X-FRAME-OPTIONS”:[“SAMEORIGIN”],”SPRequestDuration”:[“61″],”SPIisLatency”:[“1″],”Server”:[“Microsoft-IIS\/8.0″],”WWW-Authenticate”:[“Bearer realm=\”61e7a76b-024e-40d5-9185-2887a044d7cc\”,client_id=\”00000003-0000-0ff1-ce00-000000000000\”,trusted_issuers=\”00000005-0000-0000-c000-000000000000@*,00000003-0000-0ff1-ce00-000000000000@61e7a76b-024e-40d5-9185-2887a044d7cc\””,”Negotiate”,”NTLM”],”X-Powered-By”:[“ASP.NET”],”MicrosoftSharePointTeamServices”:[“″],”X-Content-Type-Options”:[“nosniff”],”X-MS-InvokeApp”:[“1; RequireReadOnly”],”Date”:[“Tue, 05 Feb 2013 19:17:31 GMT”]} {“error_description”:”The server was unable to process

I searched for information about this error and in a lot of posts the solution was to run the user profile synchronization service.

Since I couldn’t do that, I tried to run WFs in a SharePoint 2013 with sql server 2012 , with the User Profile Service Synchronization Service stoped, and I run it with no problems.