Search code examples
c#sharepointsharepoint-webservice

Get if "Allow management of content types" is checked using SharePoint WebServices


I need the information about SharePoint document library whether the "Allow management of content types" is checked or not. I have to use SharePoint web services.

I have looked up in GetListAndView method in Lists.asmx, but found no property in "List" Node or in "View" Node that refer to the management of Content Types .

Could anyone help me out please?

Thanks :)


Solution

  • You can get it from the GetList() method of lists.asmx. Look at the Flags attribute.

    Better yet, here's some sample code from https://social.technet.microsoft.com/Forums/sharepoint/en-US/9d6c26a5-279e-4f4e-8dfc-b31acff81813/web-service-to-check-if-the-management-of-content-types-are-allowed?forum=sharepointgeneralprevious

    public static bool GetAllowContentTypes(string listName)
      {
                listservice.Lists ls = new listservice.Lists();
                ls.Url = "http://basesmc2008/_vti_bin/lists.asmx";
                ls.UseDefaultCredentials = true;
                UInt64 flags = 0;
                bool contentTypesAllowed = false;
    
                XmlNode node = ls.GetList(listName);
                XElement element = XElement.Parse(node.OuterXml);
    
                var result = from e in element.Attributes("Flags")
                                                      select  e.Value;
    
                if (result != null && UInt64.TryParse(result.First().ToString(), out flags))
                    contentTypesAllowed = ((flags & ((ulong)0x400000L)) != 0L);
                else
                    return false;
    
                return contentTypesAllowed;
    
    }