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: