This article explains Site Work Flow development step-by-step.
What a Site Workflow is
Site Workflows are the workflows that apply to the entire site.
This workflow updates the company column of the following list when it runs.
Use the following procedure to create a site workflow.
Step 1: Open Visual Studio.
Step 2: Select "SharePoint" -> "2010" -> "Sequential Workflow".
Step 3: Add the name of the Workflow.
Step 4: Ensure that the Check box is checked and that history list and task list are selected.
Step 5: In the next window check the check box for User Manually start.
Step 6: Click "Finish", the next screen will display as below.
Step 7: From Toolbox select code activity.
Step 8: Inside code activity write the following lines of code:
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
using (SPWeb web = SPContext.Current.Web)
{
SPList list = web.Lists["Manager"];
foreach (SPListItem item in list.Items)
{
if (item["Company"] == null)
{
item["Company"] = "Please add company name.";
item.Update();
}
}
}
}
Step 9: Open All Site Content and click "Site Workflows".
Step 10: The Added site work flow will be shown. Click it.
Step 11: The Workflow will update the item company when it runs.