Skip to content

Conversation

@jeppesc11
Copy link

Summary

Adds a new extension method EnsureAndSetUserFields to ClientContext that provides safe assignment of user email addresses to SharePoint list item user fields with automatic user resolution and error handling.

Changes

  • Added: EnsureAndSetUserFields extension method to ClientContextExtensions.cs
  • Features:
    • Automatic user resolution using ExceptionHandlingScope for robust error handling
    • Supports batch operations for multiple field-email assignments
    • Configurable null/whitespace handling behavior
    • Follows CSOM queuing pattern (requires caller to execute operations)
      ctx.EnsureAndSetUserFields(listItem, fieldAssignments, true);
      ctx.ExecuteQueryRetry();

Usage

var fieldAssignments = new[] { ("AssignedTo", "[email protected]"), ("Author", "[email protected]") };
ctx.EnsureAndSetUserFields(listItem, fieldAssignments, clearIfNullOrWhiteSpace: true);
ctx.ExecuteQueryRetry();

Breaking Changes

None - this is a new addition that doesn't affect existing functionality.

Implements safe user field assignment with automatic user resolution
and error handling using ExceptionHandlingScope pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant