Categories: MOSS 2007 Posted by TK on 4/9/2009 5:59 AM | Comments (0)

Page copy protected against web site content infringement by Copyscape

In some cases, it may be useful to query the existing Content Types in your site collection that have an associated Workflow defined. Use this query to loop through your content types and find the ones that have workflow enabled.

         string siteCollectionName = "http://devsite";
            SPSite siteCollection = new SPSite(siteCollectionName);
            SPWeb site = siteCollection.OpenWeb();
            foreach (SPContentType contentType in site.AvailableContentTypes)
            {
               if ((contentType.Group.ToString() != "_Hidden") && (contentType.WorkflowAssociations.Count > 0))
                Console.WriteLine("Content Type Name: " + contentType.Name.ToString() + " Content Type Group: " + contentType.Group.ToString());
               
            }
            Console.WriteLine("Press any key to continue....");
            Console.Read();

I am filtering out the hidden groups and using the WorkflowAssociations property to track the content types that have workflows associated with them.

Comments

Add comment


(Will show your Gravatar icon)

  Country flag


  • Comment
  • Preview
Loading