azure-devops-extensionsazure-devops-migration-tools

Is there any way to merge fields without adding the doneMatch into the field?


We need to merge two fields into one. In the config, there is a "doneMatch" special string, and this seems to get appended to the merged field. Why is this needed, and is there a way to not have it also appended to the target field?

For example, I have:
src.fieldA = "City"
src.fieldB = "State"

I want to merge these 2 fields into target.fieldA as "City: State". However, what I end up with is "City: State##DONE##" I can change the config file so that it uses a different doneMatch but it can't be null or empty.. so if I changed it to ";", then the resulting field would be "City: State;". I have to have an end done char/string for some reason. What is this used for? If I am synching the fields with newer updates, is it going to detect the previous ##DONE## in the target.fieldA and think it's already done the merge, so would not make any new changes?

Can someone send me more info on this feature?


Solution

  • I have updated the code for v9.0.1 that changes the way that the FieldMerge works. It no longer uses doneMatch and instead requires that all 3 fields are different and then skips if it has already been done.

     if (source.Fields.Contains(config.sourceField1) && source.Fields.Contains(config.sourceField2))
                {
                    var val1 = source.Fields[config.sourceField1].Value != null ? source.Fields[config.sourceField1].Value.ToString() : string.Empty;
                    var val2 = source.Fields[config.sourceField2].Value != null ? source.Fields[config.sourceField2].Value.ToString() : string.Empty;
                    var valT = target.Fields[config.targetField].Value != null ? target.Fields[config.targetField].Value.ToString() : string.Empty;
                    var newValT = string.Format(config.formatExpression, val1, val2);
    
                    if (valT.Equals(newValT))
                    {
                        Trace.WriteLine(string.Format("  [SKIP] field already merged {0}:{1}+{2} to {3}:{4}", source.Id, config.sourceField1, config.sourceField2, target.Id, config.targetField));
                    } else
                    {
                        target.Fields[config.targetField].Value = string.Format(config.formatExpression, val1, val2) + config.doneMatch;
                        Trace.WriteLine(string.Format("  [UPDATE] field merged {0}:{1}+{2} to {3}:{4}", source.Id, config.sourceField1, config.sourceField2, target.Id, config.targetField));
                    }
    
                }
    

    https://github.com/nkdAgility/azure-devops-migration-tools/pull/529