Skip to content

Conversation

@jeppesc11
Copy link

Summary

Adds field change detection capabilities to ListItem with a new GetDifferences extension method that compares current and new field values,

Features:

• Comprehensive field type support: User, Lookup, Multi-lookup, Taxonomy, Geolocation, URL, DateTime, numeric types, and arrays
• Flexible null/empty handling: treatEmptyStringAsNull parameter for configurable empty string behavior
• Missing field handling: Treats non-existent fields as null values

Usage

var newValues = new Dictionary<string, object>
{
    ["Title"] = "Updated Title",
    ["AssignedTo"] = new FieldUserValue { LookupId = 5 },
    ["Categories"] = new[] { "Category1", "Category2" }
};

var differences = listItem.GetDifferences(newValues, treatEmptyStringAsNull: true);

foreach (var change in differences)
{
    Console.WriteLine($"Field '{change.FieldInternalName}' changed from '{change.CurrentValue}' to '{change.NewValue}'");
}

Breaking Changes

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

- Implement GetDifferences extension method to compare current and new field values
- Return FieldChange objects containing field name, new value, and current value
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