Apr 9, 2013

How to differentiate a SPD Workflow with the OOB Workflow programmatically in SharePoint

Hi guys,
As part of pre migration analysis, I have got a requirement to find the custom workflows in a web/site in 2007 env. The goal of this solution is  to generate a  report with the custom workflow details with in the web/site which were created using sharepoint designer .
This is the logic to find whether the workflow is created through designer

 private static void GetCustomWorkFlows(SPWeb web)
        {
            foreach (SPList list in web.Lists)
            {
                foreach (SPWorkflowAssociation wfAssociation in list.WorkflowAssociations)
                {
                    if (wfAssociation.BaseTemplate == null && wfAssociation.InternalName.Contains("Xoml"))
                    {
                        //SPD workflow
                    }
                    else
                    {
                        //OOB Workflow
                    }
                }
            }
        }
The base template property for the OOB (Default) workflow contains some information. But the designer workflow doesnt have the base template so it gives the null value  and also it has an internal name in the format of  xoml and cfg tags. For more information check this post.

For one of the workflow which i have created through designer these are the Name and Internal Names

Name : MySPDTestWf
Internal Name :
MySPDTestWf
<Xoml.d6bb7778_0d20_4a85_8da7_5eb6ceafcafa.2.1024.3.1024.dll>
<Cfg.d6bb7778_0d20_4a85_8da7_5eb6ceafcafa.4.1024.>


Hope Helpful...

Thanks.

No comments:

Post a Comment