-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Category
- Bug
When adding an existing site field to a content type following the instructions from https://pnp.github.io/pnpcore/using-the-sdk/contenttypes-intro.html#adding-site-fields-to-a-site-content-type
awaitcontentType.FieldLinks.AddAsync(field, required: true);
if you don't specify a Display Name then when you try and add the content type to a list, either programmatically or through the UI, you get an error like
Can not add a field without a Display Name.
Steps to reproduce
var ct = await context.Web.ContentTypes.AddAsync("<CT ID>", "<CT Name>", group: "Test");
var field = await context.Web.Fields.FirstOrDefaultAsync(f => f.InternalName == "<Field Name>");
await ct.FieldLinks.AddAsync(field);
Expected behavior
On the above AddAsync method if the optional displayName parameter is not passed then should it copy the Title from the field property? I presume the optional parameters are there to override the values from the field (I have not tested this behaviour)?
Note, workaround is to pass the display name
await ct.FieldLinks.AddAsync(field, displayName: field.Title);
Environment details (development & target environment)
- SDK version: 1.5.85-nightly
- OS: Windows Server 2022
- SDK used in: Azure Functions
- Framework: .NET 6
- Browser(s): n/a
- Tooling: Visual Studio 2022
Thanks for your contribution! Sharing is caring.