How to migrate Steps field of TestCase into new Testcase in other project RRS feed

  • Question

  • Hi,

    1. I have exported the work items details from ADO Queries to excel sheet
    2. Given input as the excel sheet to C# application , mapped the field values from excel sheet and created similar work items in an another project in ADO
    3. However, the problem exists in Test Case (Work Item Type). There is a field called as steps in Test Case ,which gets exported in excel but unfortunately while mapping it to create a work item it is empty , the data in steps is not getting mapped and remains blank in the newly created work item.

    Here is what I have done:

    1) newWorkItem.Fields["Microsoft.VSTS.TCM.Steps"].Value = a.steps;

    2) var document1 = new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchDocument();

    document1.Add( new Microsoft.VisualStudio.Services.WebApi.Patch.Json.JsonPatchOperation()

    { Path = "/fields/Microsoft.VSTS.TCM.Steps",

    Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add,

    Value="<DIV><P><SPAN xml:lang="">Hello</SPAN></P></DIV> <DIV><P> <SPAN xml:lang="">world</SPAN></P></DIV> " });

    var workitem1 = workitemClient.UpdateWorkItemAsync(document1, workitemId.Value).Result;

    However, In both the cases steps field remains empty.

    Please can you help me with this 

    One more thing when I try to migrate the same steps data in some other field of test case ex. Description. It gets saved there but in text format not in table.

    my steps field looks like this:

    • Edited by Shirin14 Tuesday, July 28, 2020 4:54 PM
    Tuesday, July 28, 2020 4:33 PM

All replies

  • Hi Shirin14,

    You could try to use postman to check if this value could be accessed:

    Use Postman to perform operations with the Web API

    Work Items - Update

    Work Items - Get Work Item

    And please check if your value is correct, it should be <steps> instead of <DIV>.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, July 29, 2020 8:26 AM
  • Hi Dylan,

    Thankyou, I will try with postman

    Yesterday, meanwhile I was trying to do it with powershell and achieved it , however with another type of hinderence

    I have used copy method in powershell to copy the workitem , it works well it copies all the fields from old workitem and creates new workitem.(even steps as it is)

    The Problem is I want to copy the workitems from one project to other project. However when I try to change the area path and Iteration path so that the copied workitem should get created in new project ,it fails and gives me error 

    Here is my script

    $oldTpc = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection([uri]$oldTpcUrl)
    $oldWorkItemStore = $oldTpc.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
    $oldItem = $oldWorkItemStore.GetWorkItem(660475)
     Write-Host "Cloning Test Case: " + $oldItem.Title
    $cloneStory = $oldItem.Copy()

    #$cloneStory.AreaPath = $oldItem.AreaPath -replace "oldareapath","newareapath"

    #$cloneStory.IterationPath = $oldItem.IterationPath -replace "oldareapath","newareapath"

    ($oldItem, $cloneStory )


    Do you have any idea


    Wednesday, July 29, 2020 8:38 AM
  • I think you need to create a new work item and assign necessary values per to old work item. The copy() way is used for the same project.
    Wednesday, July 29, 2020 11:04 AM
  • Yes, correct but again the steps remains empty if we create a workitem an assign.

    $newworkitem.Fields["Microsoft.VSTS.TCM.Steps"] = $oldworkitem.Fields["Microsoft.VSTS.TCM.Steps"]

    Wednesday, July 29, 2020 2:59 PM