Professional Documents
Culture Documents
Add New Content Type Sequentialworkflow
Add New Content Type Sequentialworkflow
Open visual studio 2010 | New Project | Sharepoint | 2010 | Choose Content Type then type name
is ActiveWorkflowWhenAddContentType
wfAssociation = wfAssociation
= SPWorkflowAssociation.CreateWebContentTypeAssociation(theWF,
WorkflowName, "Tasks","Workflow History");
if (theCT.WorkflowAssociations.GetAssociationByName(wfAssociation.Name,
web.Locale) == null)
{
theCT.WorkflowAssociations.Add(wfAssociation);
}
else
{
theCT.WorkflowAssociations.Update(wfAssociation);
}
theCT.UpdateWorkflowAssociationsOnChildren(true, true, true, false);
}
}
}
///////////////////
Uncommnet method FeatureDeactivating and paste this segment code to within it
SPWorkflowAssociation wfAssociation =
theCT.WorkflowAssociations.GetAssociationByName(WorkflowName, web.Locale);
if (wfAssociation != null)
{
theCT.WorkflowAssociations.Remove(wfAssociation);
}
theCT.UpdateWorkflowAssociationsOnChildren(true, true, true, false);
}
}
}
namespace ActiveWorkflowWhenAddContentType.Features.Feature2
{
/// <summary>
/// This class handles events raised during feature activation, deactivation,
installation, uninstallation, and upgrade.
/// </summary>
/// <remarks>
/// The GUID attached to this class may be used during packaging and should not be
modified.
/// </remarks>
[Guid("c670481c-5032-4200-9096-385bcdaba2f9")]
public class Feature2EventReceiver : SPFeatureReceiver
{
// Uncomment the method below to handle the event raised after a feature has been
activated.
wfAssociation
= SPWorkflowAssociation.CreateWebContentTypeAssociation(theWF,
WorkflowName, "Tasks", "Workflow History");
if (theCT.WorkflowAssociations.GetAssociationByName(wfAssociation.Nam
e, web.Locale) == null)
{
theCT.WorkflowAssociations.Add(wfAssociation);
}
else
{
theCT.WorkflowAssociations.Update(wfAssociation);
}
theCT.UpdateWorkflowAssociationsOnChildren(true, true, true, false);
}
}
}
// Uncomment the method below to handle the event raised before a feature is
deactivated.
// Uncomment the method below to handle the event raised after a feature has been
installed.
// Uncomment the method below to handle the event raised before a feature is
uninstalled.
// Uncomment the method below to handle the event raised when a feature is
upgrading.
Build Project
Go to Shared Documents | List Settings | Advanced settings
Allow management of content types? : choose yes | OK
Continue, click “Add from existing site content types” link as follows:
Choose DocumentSetContentType then click Add button
Result as
New DocumentSetContentType
Input full infomation
Automatically workflow run as follows: