Friday, September 30, 2011

SPWorkflow Status programmatically

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);

}

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.

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);

Monday, August 22, 2011

The default term store cannot be identified

I was trying to activate the Taxonomy on my site which created from the blank site template.When I connecting and add some properties for "Managed Meta data service" from Central application I have got this error.Initially I have no clue.I googled its WCF hotfix for service application.

when creating the "Enterprise Keyword" column,my term store was not able to find the default term store.
"The default term store cannot be identified"
After tried some attempts to create the same column below error was thrown.
Unrecognized attribute 'allowInSecureTransport'


You can download the hotfix from the below link

http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=23806