Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making content type the default for a list #775

Closed
dgtheninja opened this issue Feb 28, 2022 · 5 comments
Closed

Making content type the default for a list #775

dgtheninja opened this issue Feb 28, 2022 · 5 comments
Assignees
Labels
area: model 📐 Related to the core SDK models

Comments

@dgtheninja
Copy link
Contributor

I am converting a project on .Net 4.7 that used the old SharePointPnPCoreOnline nuget package to a new .Net Core 6 project using the Pnp.Core and PnP.Framework packages and have come up with an issue converting a piece of functionality

When adding an exisiting content type to a list we were able to make the content type the default one for the list with the 2nd property on the following
spList.AddContentTypeToListByName("contentTypeName", true);
In the new world I can add the content type, with the below but there seems to be no option to make it the default
await spList.ContentTypes.AddAvailableContentTypeAsync(siteCT.Id);

Can anyone advise on how to perform this with the new packages?

@jansenbe jansenbe assigned jansenbe and unassigned jansenbe Mar 1, 2022
@jansenbe jansenbe added the area: model 📐 Related to the core SDK models label Mar 1, 2022
@jansenbe
Copy link
Contributor

jansenbe commented Mar 1, 2022

@dgtheninja : we did not yet implement this, but it's a good one to implement. The PnP Framework method you're referring to shows how this is done: the first content type in the uniqueContentTypeOrder list (=property on IFolder) is the default one. I'm currently OOF and have limited time, but will be able to have a look at this next week.

@jansenbe jansenbe self-assigned this Mar 8, 2022
@jansenbe
Copy link
Contributor

jansenbe commented Mar 8, 2022

@dgtheninja : started working on this.

jansenbe added a commit that referenced this issue Mar 9, 2022
@jansenbe
Copy link
Contributor

jansenbe commented Mar 9, 2022

@dgtheninja : support for changing the content type order has been added, the content type you set as first is also known as the "default" content type. Docs are updated as well, see https://pnp.github.io/pnpcore/using-the-sdk/contenttypes-intro.html#getting-and-setting-the-content-type-order-in-the-list-new-menu.

Can you please give things a go and provide feedback. These updates will appear in the next nightly build (= version 1.5.85 or higher)

@dgtheninja
Copy link
Contributor Author

@jansenbe, again thanks for the swift implemention it does exactly what I need.

One small point, shouldn't the return value from the GetContentTypeOrder methods and the parameter to the ReorderContentTypes methods be IEnumerable rather than List?

@jansenbe
Copy link
Contributor

Think in this case returning a List<> is better here, see https://daedtech.com/what-to-return-ienumerable-or-ilist/. Thanks for the feedback @dgtheninja .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models
Projects
None yet
Development

No branches or pull requests

2 participants