Monday, December 13, 2010

workflow in sharepoint

copy items in one document library to another library using  sequential wokflows

This is step by step instruction to create workflows in visual tudio 2008

   -> open the visual studio 2008
  ->  select new project and then select  sharepoint sequential workflow

Type this coding :


// Get the item the workflow is running on
SPListItem item = workflowProperties.Item;


// Set the name of the document library and site
// where to copy the document to
string siteUrl = "
http://<ServerName>/<SiteName>/";
string libName = "DocLibForCopies";

// Open the site
using (SPSite site = new SPSite(siteUrl))
{
  using (SPWeb web = site.OpenWeb())
  {
    if (item.File != null)
    {
      // Copy the document to the library
      SPFolder library = web.Folders[libName];
      library.Files.Add(
        item.Name, item.File.OpenBinary());
      library.Update();
    }
  }
}

i hope you will get the solution

1 comment: