Skip to content

Align plugin Target with Dataverse for system-managed fields#344

Merged
mkholt merged 1 commit into
masterfrom
systemfields-in-target-2e0
Jul 9, 2026
Merged

Align plugin Target with Dataverse for system-managed fields#344
mkholt merged 1 commit into
masterfrom
systemfields-in-target-2e0

Conversation

@mkholt

@mkholt mkholt commented Jul 9, 2026

Copy link
Copy Markdown
Member

System fields were leaked into the plugin Target during pre-stages: ownerid was injected before PreValidation, and created/modified timestamps before PreOperation. Dataverse resolves these during the main operation, exposing them only via the post-image and the post-operation Target.

  • Core: stop injecting ownerid in HandleInternalPreOperations (keep id); extend CopySystemAttributes to reflect ownerid/ownership/statecode/ statuscode onto the post-operation Target (add OptionSetValue support).
  • CreateRequestHandler: move created/modified stamping from the pre-stage into the main operation on the persisted clone; resolve the effective owner on a local clone for the access checks only.
  • UpdateRequestHandler: drop the pre-stage modified stamping (Utility.Touch already sets the persisted values).
  • Tests: add ContactSystemFieldsProbePlugin and assertions that system fields are absent from the pre-stage Target, a caller-set ownerid stays visible, and the fields are present in the post-image and post-Target.

System fields were leaked into the plugin Target during pre-stages:
ownerid was injected before PreValidation, and created/modified
timestamps before PreOperation. Dataverse resolves these during the
main operation, exposing them only via the post-image and the
post-operation Target.

- Core: stop injecting ownerid in HandleInternalPreOperations (keep id);
  extend CopySystemAttributes to reflect ownerid/ownership/statecode/
  statuscode onto the post-operation Target (add OptionSetValue support).
- CreateRequestHandler: move created/modified stamping from the pre-stage
  into the main operation on the persisted clone; resolve the effective
  owner on a local clone for the access checks only.
- UpdateRequestHandler: drop the pre-stage modified stamping (Utility.Touch
  already sets the persisted values).
- Tests: add ContactSystemFieldsProbePlugin and assertions that system
  fields are absent from the pre-stage Target, a caller-set ownerid stays
  visible, and the fields are present in the post-image and post-Target.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns XrmMockup365 plugin Target contents with Dataverse behavior for system-managed fields across the pipeline, ensuring those fields are not visible in pre-stages and only surface via post-image / post-operation Target.

Changes:

  • Prevents ownerid / created/modified system fields from being injected into pre-stage Target, and instead stamps/publishes them during the main operation + post-operation target copy.
  • Extends post-operation Target system-attribute copy to include ownership + state/status fields (including OptionSetValue cloning).
  • Adds a diagnostic plugin and new tests asserting absence/presence of system fields at the correct pipeline stages.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/XrmMockup365Test/TestPlugins.cs Adds create-pipeline assertions for system-field visibility across stages.
tests/TestPluginAssembly365/Plugins/ContactSystemFieldsProbePlugin.cs Introduces a probe plugin to record which system fields are present in Target/post-image at each stage.
src/XrmMockup365/Requests/UpdateRequestHandler.cs Removes pre-stage modified stamping so modified fields don’t leak into pre-stage Target.
src/XrmMockup365/Requests/CreateRequestHandler.cs Moves created/modified stamping to the main create operation and resolves effective owner for security checks only.
src/XrmMockup365/Core.cs Expands system attribute list, copies additional system fields onto post-operation Target, and stops defaulting ownerid in internal pre-ops.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mkholt
mkholt merged commit 0e8ca4c into master Jul 9, 2026
3 checks passed
@mkholt
mkholt deleted the systemfields-in-target-2e0 branch July 9, 2026 09:19
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.

2 participants