cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rhood
New Member

Set a new default content type

Thanks to this forum I have now cracked, making a SharePoint document library and assigning a new custom content type from a site available list.

 

I have just found out that I need to make the new content type default.

 

I found this - https://sharepoint.stackexchange.com/questions/273329/managing-content-type-using-rest-api though it does not really discuss making a content type default.  

1 ACCEPTED SOLUTION

Accepted Solutions
rhood
New Member

GOT IT. Thank you for you input

 

rhood_0-1638977806939.png

This find the unique ID for any given doc library, filters out Documents and deletes it.

View solution in original post

7 REPLIES 7
Expiscornovus
Super User
Super User

Hi @rhood,

 

That thread is talking about the ordering. I have tried to POST request, but it wasn't working for me. It didn't change the ordering like suggested in that solution.

 

Are there any other Content types in use in your library? Otherwise you could remove those from the library and the only one left is automatically the default one. That could be a workaround.

 

If so, you could use the following URI for a POST request in a Send a HTTP request to SharePoint action for that.

 

_api/web/lists/getbytitle('@{variables('ListTitle')}')/ContentTypes('@{variables('ContentTypeId')}')/deleteObject() 

 

 

Alternatively, you could also use this PnP PowerShell cmdlet:

https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/set-pnpdefaultcontenttypetolist?vi...

 

Thanks, I had been trying that.

 

This morning I used the call below to collect the contenttypes from one of my folders.

 

_api/web/lists/getbytitle('@{variables('ListTitle')}')/ContentTypes

 

I expected to see two, Document and Email.  I wanted to delete Document but the ID deleted Email instead.

 

Looking at the two IDs in the output from the above call they seem to be the same???

 

Document - ContentType ID=\"0x0101004DAFA0A932C94645B584822535763071004C69C8D6BB964C40BDBC40D8F258493F

Email

- ContentType ID=\"0x0101004DAFA0A932C94645B584822535763071004C69C8D6BB964C40BDBC40D8F258493F

 

I would have expected each ID to be unique. Am I missing something?  I tried just 0x0101 that shows as the Document ID in SharePoint but this fails.

Expiscornovus
Super User
Super User

Hi @rhood,

 

I would also expected two different ids.

 

Do you want to run this in a GET request instead?

_api/web/lists/getbytitle('@{variables('ListTitle')}')/RootFolder/uniqueContentTypeOrder

 

This should give back a results property with the existing order.

 

Thanks,

Diving in a little more, it seems that each content type has it own unique value for each document library. 

I can delete the content type if I manually enter the correct ID so that's a good start!

To do this without manual intervention I am using get contenttype command to return all content type data: 

 

_api/web/lists/getbytitle('TEST 50')/ContentTypes

 

then running the output through several filters in order to retrieve the unique ID for document type (I may me going too far but is all I can think off).

 

rhood_3-1638974541866.png

I then pass this output to a variable

rhood_2-1638974294909.png

The value is [{"TypeID":"0x010100265C8847F1165C4980E7136341167606"}]

How do I only get 0x010100265C8847F1165C4980E7136341167606 as I with to use this variable in the final HTTP request to delete the content type?

 

rhood
New Member

GOT IT. Thank you for you input

 

rhood_0-1638977806939.png

This find the unique ID for any given doc library, filters out Documents and deletes it.

Krati22
New Member

Hey,

I have the similar requirement to set a default content type using flow. Can you please provide the solution with screenshot?

Hi,

No problem.  My solution does rely on having a single content type at the end.

Here is my full flow:

rhood_0-1642067738833.png

 

The document folder needed to have the Content type set to managed during creation:

rhood_1-1642067866901.png

I then added my new content type -Email:

rhood_2-1642068006292.png

To find the content type ID I went to Site Settings > Site content types and choose the relevant content type

rhood_3-1642068208967.png

Now from here was a lot of trial and error as I could not find a way to just set Email as the default content type so as mentioned above I rely on deleting the only other document type - Document. This then forces Email to become the default.

 

What I seemed to find was that using the same method as above to find the content ID did not work.  From what I could see, the ID was unique to each document library so I needed to extract this information:

 

rhood_5-1642068587751.png

I then ran the results through Parse JSON to get access to the variables:

rhood_6-1642068635420.png

As there are more than one content type I further filtered the result (someone with more knowledge here could likely do this more efficiently):

rhood_7-1642068860134.png

Then finally I used this ID to delete the document content ID leaving me with Email as the default. Stringid held the value.

 

rhood_8-1642068932333.png

 

I hope this helps!

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Users online (1,514)