Using this create list in site level when the work flow activated in site level.
Step 1: Open VS with new empty SharePoint project in farm solution.
Step 2: Add a new item Sequential Workflow for site workflow.
Step 3: Choose Site workflow Option.
Step 4: Click Next And Finish.(Using site work flow we start manually by default).
Step 5: ClickOnworkflowActivity.
Step 6: Write Following Code.
- private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
- {
- SPWeb topsite = workflowProperties.Web;
- topsite.Lists.Add("Hello", " ", SPListTemplateType.Contacts);
- SPList listcon = topsite.Lists["Hello"];
- listcon.OnQuickLaunch = true;
- listcon.Update();
- topsite.Update();
- }
After the deploy the project.Then go to site contents in our share point site.click site workflows and start that workflow and the output become create our list in that site.