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
Hello. My goal is to preserve modification time after value is assigned to a custom property of SharePoint file (unfortunately it changes modification time, what is not desired). I did follow example from ticket. The query did not return exception. Actually I got positive response (if time format was wrong I was getting item.HasException == True), but still it did not influence 'Modified:' property correctly. Actually, file modification time was updated to the time of when this request was sent!
This is the code I've written:
def mark_processed(self, file):
'''Set property of SharePoint file indicating that it was processed'''
file_id = file.listItemAllFields.get().execute_query().id
file_item = self.ctx.web.lists.get_by_title(self.sharepoint_lib).get_item_by_id(file_id).get().execute_query()
file_metadata = file_item.properties
property_name = self.processed_poperty_name()
if not property_name in file_metadata.keys():
self.create_property(property_name)
now_str = datetime.today().strftime(SP_DATE_WRITE_FORMAT)
mdate_utc = datetime.strptime(file_metadata['Modified'], SP_DATE_READ_FORMAT)
mdate_str = mdate_utc.replace(tzinfo=tz.utc).astimezone().strftime(SP_DATE_WRITE_FORMAT)
client_result = file_item.validate_update_list_item(
{
property_name: now_str,
'Modified': mdate_str # Does not work
}
).execute_query()
self.raise_for_o365(client_result)
logger.debug('Set property %s of %s as %s', property_name, file.serverRelativeUrl , now_str)
def raise_for_o365(self, result):
'''Raise exception if o365 request finished with exception'''
for item in result.value:
if item.HasException:
raise requests.RequestException(f'SharePoint API resulted with error: {item.ErrorMessage}')
The text was updated successfully, but these errors were encountered:
r2oro
changed the title
Problem with setting of SP ile modification date (preserving it after of custom property)
Problem with setting of SP file modification date (preserving it after update of custom property)
Jul 20, 2023
r2oro
changed the title
Problem with setting of SP file modification date (preserving it after update of custom property)
Problem with setting of SP file modification date (preserving it through update of custom property)
Jul 20, 2023
@dkuska - thanks for responding, I do work with Document Library. Does it have differently in case of Tasks library? @vgrem provided code here ((#330)) which according to him does preserve modification time.
Hello. My goal is to preserve modification time after value is assigned to a custom property of SharePoint file (unfortunately it changes modification time, what is not desired). I did follow example from ticket. The query did not return exception. Actually I got positive response (if time format was wrong I was getting
item.HasException == True
), but still it did not influence 'Modified:' property correctly. Actually, file modification time was updated to the time of when this request was sent!This is the code I've written:
The text was updated successfully, but these errors were encountered: