I have an document folders which associated with multiple workflows,This code snippet find the specific workflow name and its status.
This code has been developed for my requirement,I need to copy the document to another folder as soon as "Workflow completed".
Associated with List Workflow events in event receiver template.
public override void WorkflowCompleted(SPWorkflowEventProperties properties)
{
using (SPSite site = new SPSite(properties.WebUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = properties.ActivationProperties.List;
foreach (SPListItem item in list.Items)
{
foreach (SPWorkflow wf in item.Workflows)
{
if (list.WorkflowAssociations[wf.AssociationId].Name.ToString() == "MultipleTasksFlow")
{
string WFStatus = item[list.WorkflowAssociations[wf.AssociationId].Name].ToString();
}
}
}
}
}
base.WorkflowCompleted(properties);
}
Friday, September 30, 2011
Saturday, September 10, 2011
Getting SPWeb ref inside workflow programmatically
If you want to get SPWeb reference inside the OnTaskChanged_Invoked or Task_MethodInvoking
method
SPWorkflowActivationProperties workflowProperties= new SPWorkflowTaskProperties();
SPWeb web = workflowProperties.Web;
you can get the SPWeb properties of "SPWorkflowActivationProperties" class.
SPContext or HttpContext will not works inside the SharePoint Workflow.
This single line snippet saved my lot of developing hours to trigger the workflow programmatically.
method
SPWorkflowActivationProperties workflowProperties= new SPWorkflowTaskProperties();
SPWeb web = workflowProperties.Web;
you can get the SPWeb properties of "SPWorkflowActivationProperties" class.
SPContext or HttpContext will not works inside the SharePoint Workflow.
This single line snippet saved my lot of developing hours to trigger the workflow programmatically.
Thursday, September 08, 2011
Creating SubFolder in SharePoint 2010
Creating SubFolder in SharePoint 2010
n1="FolderName"; SPList list = site.Lists.TryGetList("Shared Documents"); SPFolderCollection cols = list.RootFolder.SubFolders; SPFolder docFolder = cols.Add("/Shared Documents/" + n1);
Subscribe to:
Posts (Atom)