You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in a Sharepoint list, if we have a field that is not initially set, it is not possible to update it to a new value.
Context :
i = l.get_item_by_id(x)
i.fields # > does not contain any "Status" field as "Status" is not set for this item
i._parent.column_name_cw.value() # > but this contain "Status" value
in that case, update_field raise an error :
i.update_fields({'Status': 'Inactif'})
Traceback (most recent call last):
File "", line 1, in
File "/home/bruno/src/o365/lib/python3.12/site-packages/O365/sharepoint.py", line 154, in update_fields
raise ValueError('"{}" is not a valid internal field name'.format(field))
Explanation :
This is due to the fact that self.fields exists, but not contains the field,
and second condition is never tested.
def _valid_field(self, field):
# Verify the used field names are valid internal field names
valid_field_names = self.fields if self.fields \
else self._parent.column_name_cw.values() \
if self._parent \
else None
if valid_field_names:
return field in valid_field_names
Solution:
I would suggest to switch the 2 conditions like this :
def _valid_field(self, field):
# Verify the used field names are valid internal field names
valid_field_names = self._parent.column_name_cw.values() if self._parent \
else self.fields if self.fields \
else None
# If no parent is given, and no internal fields are defined assume correct, API will check
if valid_field_names is None:
return True
return field in valid_field_names
The text was updated successfully, but these errors were encountered:
I don't see any usual case, except perhaps when a field is added.
I have always seen at least self.fields or parent.column_name set
but self.fields contain only fields that have values in Sharepoint list record.
(A bit annoying to rely on that if we want to set a such field).
Hi,
in a Sharepoint list, if we have a field that is not initially set, it is not possible to update it to a new value.
Context :
i = l.get_item_by_id(x)
i.fields # > does not contain any "Status" field as "Status" is not set for this item
i._parent.column_name_cw.value() # > but this contain "Status" value
in that case, update_field raise an error :
Explanation :
This is due to the fact that self.fields exists, but not contains the field,
and second condition is never tested.
Solution:
I would suggest to switch the 2 conditions like this :
The text was updated successfully, but these errors were encountered: