In This article we will discuss about site workflows.
Site work flow is not to a specific list or library you can run on any one of those.
In this example we will create a new Custom List Called Product List and take the data of existing Product List to the new Product list as a backup.
Prerequisite: Make sure that your site is having Product List.
Open visual studio.
Open File-- > New-- > project.
From SharePoint -- > 2010 -- > Select Sequential Workflow.
Give name as Site workflow.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6t4g68hBsXLkmd31bnyzFHCoDPvRxpkLKgS_ACukpEveTXGBfIWVsFTecirpG3GiGhDpJPxjBzwQLov_Vv6lUIS1kpFxI0Wgq6e2f53yby5bb8EW_Y8YmF2-8dhRbNGjuteS2AS7BBadq/s530/1.jpg)
Deploy as form solution.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDfRLrcGkhETs7yKjEVYIz7A0fZUEfhyphenhyphenM4fhxTMuXrH06ZDXxLpV7xegS8d8z8iOZC7C1cq3BoDP2TQjrJJ7_R0y2y3P6kbZ3Ey0Fq5M_AR4Z5jc0no3wXVXF-pHYRbAmmIjWReWfa3eRt/s530/2.jpg)
Click Next.
Select Site workflow.
Give the workflow name which you like.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9jXIWP-wgtcx5RxnVPbMhzWwv8nwq0TjrnrOmxi5OravqEg0NlKdFcLcu20YTvkeUsU36rv8JwdFeecME_2Z9GXgvORNWBpEQeFotL4fuiOMpYbOCwRqMNXGqw7pjmZkJI3y-TTV_cfnB/s530/3.jpg)
Click Next.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4YiW_iko3mJXVVVt4nZ4q7zv4emvQFbMuxAok7qGBFw-FwH7V6e744A9bsCI7Mgdia3ByLVqqPojOf1x3aobmmnGzc1DrsdD-PffsfUJ4mtVv3sPnZYyti3mkOBQa3OEpI92XdjgjPB4O/s530/4.jpg)
Click Next.
Here you can see only manually started option available.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibpema21AAiJq3QloLNgNnGX6d38LIJ31dESETD2Q_vLEwtSJnMWY_HEwYeMJOa5xV6WgRfqqjrCj2VjOBSFAPwMPoI615LUgpNMAD5hNLFBO7z1yG0bLXR2KV5geOqPx60qzBq1-UZVMA/s530/5.jpg)
Click Finish. It will show the below project structure.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_MwYuc3wMDr1EwsvkwLhm3DpdC8qJImFSrxgDBU15PY2UUaeq3k38Pys_wa41xsHLJhreklNnVwcTMyLCV0iFrYw06GWgU2QNRpvKqEHMuiTzeC2vf-jA_CjrVV_SUMN_h-AGi6u63HHY/s320/6.jpg)
If you want to change the URL of site to deploy, go to properties of the project (F4). Change the Site URL property.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzTJ9CeT-pgSbnOB8MEHAqGzgu3PVSZt5R0Wl713-JYUkw3G8XitqyOBjrcKWqnwwch2IHY1lzsVPoQaijmM1YCQs4y2UlaPzmN3M5oI5wWCV5QnpjctKuZ4QdbPhr72-1uP1QemWUKpNY/s530/9.jpg)
Create Class1 from toolbox and drag and drop below onworkflowactivated.
Open the class1.cs file and paste the below code.
Build and deploy the solution.
Observe the output window.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEaRtiH_FpYqLhSHXOOQswBg1BdebbkBxLE7dry_9F_Eloin5BqiA3hxF9nC-HPqEwGVETLLB-WJ0NebYx1NMTrgNMmHMiDiBFMpfex_7Ppwvu8tsZXb0lwGpdhmoH25fouJDVYEW3gdSO/s530/8.jpg)
Open the site URL and check, you will have a ProductsBackup list created with the Products List data.
Hope you found this useful.
SharePoint-Journey for Administrators, Developers and users
Site work flow is not to a specific list or library you can run on any one of those.
In this example we will create a new Custom List Called Product List and take the data of existing Product List to the new Product list as a backup.
Prerequisite: Make sure that your site is having Product List.
Open visual studio.
Open File-- > New-- > project.
From SharePoint -- > 2010 -- > Select Sequential Workflow.
Give name as Site workflow.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6t4g68hBsXLkmd31bnyzFHCoDPvRxpkLKgS_ACukpEveTXGBfIWVsFTecirpG3GiGhDpJPxjBzwQLov_Vv6lUIS1kpFxI0Wgq6e2f53yby5bb8EW_Y8YmF2-8dhRbNGjuteS2AS7BBadq/s530/1.jpg)
Deploy as form solution.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDfRLrcGkhETs7yKjEVYIz7A0fZUEfhyphenhyphenM4fhxTMuXrH06ZDXxLpV7xegS8d8z8iOZC7C1cq3BoDP2TQjrJJ7_R0y2y3P6kbZ3Ey0Fq5M_AR4Z5jc0no3wXVXF-pHYRbAmmIjWReWfa3eRt/s530/2.jpg)
Click Next.
Select Site workflow.
Give the workflow name which you like.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9jXIWP-wgtcx5RxnVPbMhzWwv8nwq0TjrnrOmxi5OravqEg0NlKdFcLcu20YTvkeUsU36rv8JwdFeecME_2Z9GXgvORNWBpEQeFotL4fuiOMpYbOCwRqMNXGqw7pjmZkJI3y-TTV_cfnB/s530/3.jpg)
Click Next.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4YiW_iko3mJXVVVt4nZ4q7zv4emvQFbMuxAok7qGBFw-FwH7V6e744A9bsCI7Mgdia3ByLVqqPojOf1x3aobmmnGzc1DrsdD-PffsfUJ4mtVv3sPnZYyti3mkOBQa3OEpI92XdjgjPB4O/s530/4.jpg)
Click Next.
Here you can see only manually started option available.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibpema21AAiJq3QloLNgNnGX6d38LIJ31dESETD2Q_vLEwtSJnMWY_HEwYeMJOa5xV6WgRfqqjrCj2VjOBSFAPwMPoI615LUgpNMAD5hNLFBO7z1yG0bLXR2KV5geOqPx60qzBq1-UZVMA/s530/5.jpg)
Click Finish. It will show the below project structure.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_MwYuc3wMDr1EwsvkwLhm3DpdC8qJImFSrxgDBU15PY2UUaeq3k38Pys_wa41xsHLJhreklNnVwcTMyLCV0iFrYw06GWgU2QNRpvKqEHMuiTzeC2vf-jA_CjrVV_SUMN_h-AGi6u63HHY/s320/6.jpg)
If you want to change the URL of site to deploy, go to properties of the project (F4). Change the Site URL property.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzTJ9CeT-pgSbnOB8MEHAqGzgu3PVSZt5R0Wl713-JYUkw3G8XitqyOBjrcKWqnwwch2IHY1lzsVPoQaijmM1YCQs4y2UlaPzmN3M5oI5wWCV5QnpjctKuZ4QdbPhr72-1uP1QemWUKpNY/s530/9.jpg)
Create Class1 from toolbox and drag and drop below onworkflowactivated.
Open the class1.cs file and paste the below code.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; namespace Product Backup { public class Class1 : System.Workflow.ComponentModel.Activity { public Class1() { } protected override System.Workflow.ComponentModel.ActivityExecutionStatus Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext) { try { SPSite site = SPContext.Current.Site; SPWeb web = site.OpenWeb(); SPList aList = web.GetList("/Lists/ Product s"); try { SPList bList = web.GetList("/Lists/ ProductsBackup"); bList.Delete(); } catch { } Guid newAnnID = web.Lists.Add("ProductsBackup", "A backup Product s list.", SPListTemplateType.GenericList); SPList bakList = web.Lists[newAnnID]; foreach (SPListItem item in aList.Items) { SPListItem newAnnItem = bakList.Items.Add(); foreach (SPField field in aList.Fields) { if (!field.ReadOnlyField) newAnnItem[field.Id] = item[field.Id]; } newAnnItem.Update(); } bakList.OnQuickLaunch = true; bakList.Update(); } catch (Exception errx) { } return base.Execute(executionContext); } } }
Build and deploy the solution.
Observe the output window.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEaRtiH_FpYqLhSHXOOQswBg1BdebbkBxLE7dry_9F_Eloin5BqiA3hxF9nC-HPqEwGVETLLB-WJ0NebYx1NMTrgNMmHMiDiBFMpfex_7Ppwvu8tsZXb0lwGpdhmoH25fouJDVYEW3gdSO/s530/8.jpg)
Open the site URL and check, you will have a ProductsBackup list created with the Products List data.
Hope you found this useful.
SharePoint-Journey for Administrators, Developers and users
good information
ReplyDeletesharepoint 2013 administration certification