sharepoint-ruby icon indicating copy to clipboard operation
sharepoint-ruby copied to clipboard

ContentTypesEnabled always displays as True

Open klondikemarlen opened this issue 5 years ago • 2 comments

What isn't working?

When I create or load a document library with the ContentTypesEnabled property set to false the field value always shows as true. The JSON that Sharepoint itself returns has the correct value.

Why do I care?

I want this value set to false so I can get the "+ add document" button to display a list of document types to add.

What did I try?

I dug around for a while but couldn't come up with a fix, though it appears to be something to do with the Sharepoint::ObjectProperties#add_property method.

Edited I'm using SharePoint 2013 + NTLM authentication

klondikemarlen avatar Feb 15 '20 01:02 klondikemarlen

Authentication doesn't even work for me anymore, and I can't figure it out for the life of me... I'm not even sure it comes from the gem, as I can't even produce a correct authentication query from Postman.

I'll have to debug this in the crudest possible way. Can you provide me with some code reproducing the issue, and the content of the Sharepoint JSON response containing the expected ContentTypesEnabled value ?

Plaristote avatar Apr 09 '20 09:04 Plaristote

Hey! Last I checked Postman doesn't support NTLM properly so won't work. I had some success with Insomnia. I think I just gave up in the end.

The code I used to create the library went something like this:

site.query(:post, 'lists', {
        '__metadata' => { 'type' => 'SP.List' },
        'Title' => name,
        'Description' => description || "Document library for #{name}.",
        'BaseTemplate' => Sharepoint::LIST_TEMPLATE_TYPE[:DocumentLibrary],
        'AllowContentTypes' => true,
        'ContentTypesEnabled' => true,
        'EnableVersioning' => true
      }.to_json)

But when I next queried the library library = site.query :get, "Lists/GetByTitle('#{encoded_name}')" I then tried library.content_types_enabled and it was false.

I believe the JSON blob looked something like:

  {"d":{
      "__metadata":{
        "id":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')",
        "uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')",
        "etag":"\"0\"",
        "type":"SP.List"
      },
      "FirstUniqueAncestorSecurableObject":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/FirstUniqueAncestorSecurableObject"}},
      "RoleAssignments":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/RoleAssignments"}},
      "ContentTypes":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/ContentTypes"}},
      "DefaultView":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/DefaultView"}},
      "EventReceivers":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/EventReceivers"}},
      "Fields":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/Fields"}},
      "Forms":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/Forms"}},
      "InformationRightsManagementSettings":{"__deferred":{"uri":"http://<site url>/_api/Web/Lists(guid'8ade7551-f53c-48c5-9d2b-e89f6528cf47')/InformationRightsManagementSettings"}},
      "AllowContentTypes":true, 
      "BaseTemplate":100, 
      "BaseType":0, 
      "ContentTypesEnabled":true, 
      "Created":"2013-02-02T21:11:56Z",
      "DefaultContentApprovalWorkflowId":"00000000-0000-0000-0000-000000000000",
      "Description":"",
      "Direction":"none",
      "DocumentTemplateUrl":null, 
      "DraftVersionVisibility":0, 
      "EnableAttachments":true, 
      "EnableFolderCreation":false, 
      "EnableMinorVersions":false, 
      "EnableModeration":false, 
      "EnableVersioning":true,
      "EntityTypeName":"ANewList",
      "ForceCheckout":false, 
      "HasExternalDataSource":false, 
      "Hidden":false, 
      "Id":"8ade7551-f53c-48c5-9d2b-e89f6528cf47",
      "ImageUrl":"/_layouts/15/images/itgen.png?rev=23",
      "IrmEnabled":false, 
      "IrmExpire":false, 
      "IrmReject":false, 
      "IsApplicationList":false, 
      "IsCatalog":false, 
      "IsPrivate":false, 
      "ItemCount":1, 
      "LastItemDeletedDate":"2013-02-02T21:11:56Z",
      "LastItemModifiedDate":"2013-02-03T22:17:55Z",
      "ListItemEntityTypeFullName":"SP.Data.ANewListItem",
      "MultipleDataList":false, 
      "NoCrawl":false, 
      "ParentWebUrl":"/",
      "ServerTemplateCanCreateFolders":true, 
      "TemplateFeatureId":"00bfea71-de22-43b2-a848-c05709900100",
      "Title":"ANewList"
    }}

klondikemarlen avatar Apr 09 '20 14:04 klondikemarlen