You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor FieldToFieldMap for validation and logging (#2997)
Refactored the `InternalExecute` method by introducing a new `IsValid`
method to centralize validation logic, improving maintainability and
readability. Enhanced logging for both skipped and successful field
mappings, providing detailed context for debugging.
Added support for default values when source fields are null or empty.
Introduced new namespaces and static imports to support additional
functionality. Improved error handling with detailed warnings for
validation failures. Cleaned up code for better readability and
maintainability.
Log.LogWarning("FieldToFieldMap: [SKIPPED] Field mapping from '{SourceField}' to '{TargetField}' was skipped due to validation failures | Source WorkItem: {SourceId} -> Target WorkItem: {TargetId} | Mode: {FieldMapMode}",
if(string.IsNullOrEmpty(value)&&Config.defaultValueis not null)
57
65
{
58
66
value=Config.defaultValue;
59
67
}
68
+
60
69
target.Fields[Config.targetField].Value=value;
61
-
Log.LogDebug("FieldToFieldMap: [UPDATE] field mapped {0}:{1} to {2}:{3} as {4}",source.Id,Config.sourceField,target.Id,Config.targetField,Config.fieldMapMode.ToString());
70
+
Log.LogDebug("FieldToFieldMap: [UPDATE] Successfully mapped field {SourceField} to {TargetField} with value '{Value}' using mode {FieldMapMode} | Source WorkItem: {SourceId} -> Target WorkItem: {TargetId}",
Log.LogWarning("FieldToFieldMap: [VALIDATION FAILED] Source field '{SourceField}' does not exist on source WorkItem {SourceId}. Please verify the field name is correct and exists in the source work item type. Available fields can be checked in Azure DevOps work item customization.",
83
+
Config.sourceField,source.Id);
84
+
valid=false;
85
+
}
86
+
if(!target.Fields.Contains(Config.targetField))
87
+
{
88
+
Log.LogWarning("FieldToFieldMap: [VALIDATION FAILED] Target field '{TargetField}' does not exist on target WorkItem {TargetId}. Please verify the field name is correct and exists in the target work item type. You may need to add this field to the target work item type or update your field mapping configuration.",
89
+
Config.targetField,target.Id);
90
+
valid=false;
91
+
}
92
+
break;
93
+
caseFieldMapMode.TargetToTarget:
94
+
if(!target.Fields.Contains(Config.sourceField))
95
+
{
96
+
Log.LogWarning("FieldToFieldMap: [VALIDATION FAILED] Source field '{SourceField}' does not exist on target WorkItem {TargetId}. In TargetToTarget mode, both source and target fields must exist on the target work item. Please verify the source field name is correct.",
97
+
Config.sourceField,target.Id);
98
+
valid=false;
99
+
}
100
+
if(!target.Fields.Contains(Config.targetField))
101
+
{
102
+
Log.LogWarning("FieldToFieldMap: [VALIDATION FAILED] Target field '{TargetField}' does not exist on target WorkItem {TargetId}. In TargetToTarget mode, both source and target fields must exist on the target work item. Please verify the target field name is correct.",
0 commit comments