From 86ad83c37fe7e13a04ad03248143e94410cc2ce0 Mon Sep 17 00:00:00 2001 From: Alexander Hjelm Date: Thu, 22 Aug 2024 08:49:25 +0200 Subject: [PATCH] Update WitClientUtils.cs --- .../WorkItemImport/WitClient/WitClientUtils.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs b/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs index 70312b4d..d5055f11 100644 --- a/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs +++ b/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs @@ -1059,10 +1059,16 @@ private void AddSingleLinkToWorkItemAndSave(WiLink link, WorkItem sourceWI, Work } } }, - JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, WiFieldReference.ChangedBy, changedBy), JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, WiFieldReference.ChangedDate, changedDate) }; + if (!string.IsNullOrEmpty(changedBy)) + { + linkPatchDocument.Add( + JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, WiFieldReference.ChangedBy, changedBy) + ); + } + if (sourceWI.Id.HasValue) _witClientWrapper.UpdateWorkItem(linkPatchDocument, sourceWI.Id.Value, settings.SuppressNotifications); else @@ -1094,10 +1100,16 @@ private void RemoveSingleLinkFromWorkItemAndSave(WiLink link, WorkItem sourceWI, Operation = Operation.Remove, Path = "/relations/"+relIndex }, - JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, WiFieldReference.ChangedBy, changedBy), JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, WiFieldReference.ChangedDate, changedDate) }; + if (!string.IsNullOrEmpty(changedBy)) + { + linkPatchDocument.Add( + JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, WiFieldReference.ChangedBy, changedBy) + ); + } + if (sourceWI.Id.HasValue) _witClientWrapper.UpdateWorkItem(linkPatchDocument, sourceWI.Id.Value, settings.SuppressNotifications); else