Question

I need to do a scheduled or manually trigger update on some hidden properties of files and folders. The items all have different content types with different properties, but the hidden properties are added to the root CT, so that is no problem. Every thing works fine, but some CTs have a required date with validation. Now, when i update the hidden properties, i get a validation error.

The validation checks if the entered date is within the last 30 days. When im updating old files the set date is not valid anymore (since its older than 30 days).

When changing parameters in SharePoint its no problem, because it's only validating the changed fields. But the Update function somehow triggers validation on all properties. Is there a way to update properties without triggering the validation other than removing the validation for the update?

Code:

public static void UpdateMetadataOfFiles(ClientContext siteContext, Dictionary<string, string> metadata, List<string> files)
{
    files.ForEach(file =>
    {
        ListItem item = siteContext.Web.GetListItem(file);
        metadata.ToList().ForEach(meta => item.Properties[meta.Key] = meta.Value);
        item.Update();
    });

    siteContext.ExecuteQueryWithIncrementalRetry();
}

The ExecuteQueryWithIncrementalRetry is a ExecuteQuery wrapper suggested by Microsoft to avoid getting throttled

Était-ce utile?

La solution

We found the problem. It was on our side. We have a event receiver which does some tasks in the background, including the validation.

We talked to our customer and decided to remove the validation, since it isn't required anymore.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top