Updating choice field choices revisited #1518
Unanswered
HBSbwilliamson
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am attempting to update the choices for a custom choice field added to the Document content type in a list using PnPCore 1.14.0.
var list = await context.Web.Lists.GetByTitleAsync(libraryname, p => p.Fields, p => p.ContentTypes.QueryProperties(p => p.Name, p => p.Description,p =>p.SchemaXml,
p => p.FieldLinks.QueryProperties(p => p.Name), p => p.Fields.QueryProperties(p => p.InternalName,
p => p.Title,
//p => p.Choices,
p => p.SchemaXml
)));
var listContentTypes = list.ContentTypes;
var contentTypeToUpdate = listContentTypes.AsRequested().FirstOrDefault(p => p.Name == "Document");
var ctSchemaXml = contentTypeToUpdate.SchemaXml;
var fieldToUpdate = contentTypeToUpdate.Fields.AsRequested().FirstOrDefault(p => p.InternalName == spFieldName);
fieldToUpdate.Choices = choiceList.ToArray();
await fieldToUpdate.UpdateAsync();
//await contentTypeToUpdate.UpdateAsync();
The UpdateAsync on fieldToUpdate always produces
Message: Cannot find resource for the request SP.RequestContext.current/web/ContentTypes('0x010100E3C128FDC8D794439FA285FFF8E31A45')/.
The UpdateAsync on contentTypeToUpdate produces
Message: An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.
With no details about the field causing the error.
We are operating without sites read all permission for the app registration because of security concerns, so this may not be possible or there may be something else missing.
Also tried updating SchemaXml directly for the field with similar results.
NDA
NDA
Utility Bill
LOA
Asset Details
Asset Documents
Proforma
LOI
Proposal
Facilities
Assets
Contacts
Submit
Contract
W-9
Enroll
Renewal
Other
Is there a different way to accomplish this?
Beta Was this translation helpful? Give feedback.
All reactions