Skip to content

Added EnsureAndSetUserFields method to ClientContextExtensions#1201

Open
jeppesc11 wants to merge 1 commit intopnp:devfrom
jeppesc11:feature/ensure-user
Open

Added EnsureAndSetUserFields method to ClientContextExtensions#1201
jeppesc11 wants to merge 1 commit intopnp:devfrom
jeppesc11:feature/ensure-user

Conversation

@jeppesc11
Copy link
Copy Markdown

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", "user1@contoso.com"), ("Author", "user2@contoso.com") };
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