-
Notifications
You must be signed in to change notification settings - Fork 194
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
Cannot update MaxLength property on a text field #1541
Comments
@tomasz-sintel : can you try updating the |
@jansenbe There is no Consider the following piece of code: public record XmlValue(string AttributeName, string Value);
// ...
// GetUpdatedSchemaXml is just an XML transformation method
field.SchemaXml = GetUpdatedSchemaXml(field.SchemaXml, new XmlValue("MaxLength", "123"));
field.Title = "Some Title";
field.EnforceUniqueValues = true;
field.Indexed = true;
field.Required = true;
await field.UpdateAsync(); In the example above the code only works if the SchemaXml is set as the first operation. If I move it below the What is your recommendation? Is it safe to keep it as presented above or would I need to turn to setting ALL From my colleague's experiment I know, that the problem is the same for any dedicated field properties in other field types, e.g. [UPDATE] |
Like you mentioned in your initial comment, some more testing is needed with using the "right" type when building the update payload (would be a change in Core SDK). In the meantime please try with reading/updating/writing SchemaXML |
Ok, thanks. I'll let you decide what to do with this bug. |
You've any feedback here @tomasz-sintel ? |
Yes, from my side working with ((Field)field).Metadata["type"] = "SP.FieldText"; It's suppose to work, but I haven't used it, since I already got it to work with the |
Currently this code: |
Category
Describe the bug
After retrieving fields from a list, I am trying to update some of their properties. I query the fields with the
f => f.All
include flag to have all of the props present. At the moment I am only interested in Single Line Text Field fields, so I filter them out. I can see the prop values loaded properly. I am able to update properties like Title, Required, Unique, Indexed successfully. But after I had added setting theMaxLength
property, the code fails with a message:The property 'MaxLength' does not exist on type 'SP.Field'. Make sure to only use property names that are defined by the type.
I am working with a batch to group multiple field updates into a single operation. But I have also tried to update each field individually with no success.
Steps to reproduce
Expected behavior
I expect the request not to fail :)
Environment details (development & target environment)
Additional context
Exception details:
Message: SharePoint Rest service exception
Source: PnP.Core
StackTrace:
Inner Exception: null
Error (partial):
HttpResponseCode: 400
Message: The property 'MaxLength' does not exist on type 'SP.Field'. Make sure to only use property names that are defined by the type.
Type: SharePointRestServiceError
HResult: -2146233088
Additionally...
I have peeked the request data and the type of the field being updated in the request payload is set to
SP.Field
. I am not sure, but maybe this value should be set to the specific field's type, e.g.SP.FieldText
. I have a suspicion that setting other field types' exclusive properties may lead to the same problem.Thanks for your contribution! Sharing is caring.
The text was updated successfully, but these errors were encountered: