private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
{
SPSite mySourceSite = new SPSite("http://productionsrv:2012/Lists/anandh/AllItems.aspx/");
SPWeb mySourceWeb = mySourceSite.OpenWeb();
SPList mySourceList = mySourceWeb.Lists["anandh"];
SPListItem mySourceListItem = workflowProperties.Item;
//SPQuery mySourceListQuery = new SPQuery();
//mySourceListQuery.Query = "";
//SPListItemCollection` mySourceItemColl = mySourceList.GetItems(mySourceListQuery);
////int count = 0;
//foreach (SPListItem mySourceListItem in mySourceItemColl)
//{
string SourceEmpId = mySourceListItem["emp"].ToString();
string SourceEmpName = mySourceListItem["emp name"].ToString();
string SourceDesig = mySourceListItem["emp id"].ToString();
string SourceAge = mySourceListItem["salary"].ToString();
SPSite myDestinationSite = new SPSite("http://productionsrv:2012/Lists/kamal/AllItems.aspx/");
SPWeb myDestinationWeb = myDestinationSite.OpenWeb();
SPList myDestinationList = myDestinationWeb.Lists["kamal"];
SPListItem myDestinationListItem = myDestinationList.Items.Add();
myDestinationListItem["emp"] = SourceEmpId;
myDestinationListItem["emp name"] = SourceEmpName;
myDestinationListItem["emp id"] = SourceDesig;
myDestinationListItem["salary"] = SourceAge;
myDestinationWeb.AllowUnsafeUpdates = true;
myDestinationListItem.Update();
myDestinationWeb.AllowUnsafeUpdates = false;
//count++;
//Console.WriteLine(count+" item(s) copied");
//}
}
Try this,it will work
enter the full steps for this workflow.
ReplyDelete