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.

@jeppesc11 jeppesc11 closed this Nov 23, 2025
@jeppesc11
Copy link
Author

I have committed too many files that are not relevant to this PR

@jeppesc11
Copy link
Author

Created new PR with the correct files #1201

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