question

LoveToCode-0935 avatar image
0 Votes"
LoveToCode-0935 asked LoveToCode-0935 edited

Work item - how to add a related / child workitem in vb.net

Hi, how can I add a linked / child workitem in vb.net. Below is my piece of code. - updated, I'm using the WorkItemLinks class. I also get an error on the source property that it's set to null.


       JDocOpearion = New JsonPatchOperation

             With JDocOpearion
                 .Path = "/relations/-"
                 .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
                 Dim link = New WorkItemLink
                 .Value = link.Rel = "System.LinkTypes.Hierarchy-Reverse" _
                 & link.Source.Url = witlink.Source.Url


             End With

             JSDocument.Add(JDocOpearion)
dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LoveToCode-0935 avatar image
0 Votes"
LoveToCode-0935 answered LoveToCode-0935 edited

I figured it out. here's what I did. @Viorel-1 . Please suggest if there's also a better way to do. I love to code. Thank you :)

       JDocOpearion = New JsonPatchOperation
    
                 Dim SRCWitem As New WorkItem
                 Dim WitRelations As New WorkItemRelation
    
                 SRCWitem = WitClient.GetWorkItemAsync(SourceWorkItemID).Result
    
                 WitRelations.Rel = "System.LinkTypes.Hierarchy-Reverse"
                 WitRelations.Title = "Azure devops"
                 WitRelations.Url = SRCWitem.Url
    
                 With JDocOpearion
                     .Path = "/relations/-"
                     .Operation = Microsoft.VisualStudio.Services.WebApi.Patch.Operation.Add
                     .Value = WitRelations  /* I added the workitemrelations object */
                 End With
                 JSDocument.Add(JDocOpearion)
    
                 Dim a As Object
                 a = WitClient.CreateWorkItemAsync(JSDocument, ProjectName, "Epic")


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


If it finally works then do not touch it, or at least remove New from ‘Dim SRCWitem As New WorkItem’ and rename JDocOpearion to JDocOperation or operation.


0 Votes 0 ·

Thank you for pointing me to the right direction how to use JSON to add multiple properties. Oh I never saw that typo in JDocOpearion :) thanks again

0 Votes 0 ·