Closed dgtlrift closed 5 years ago
@dgtlrift, there is no "clean" way (yet) to do it with our library.
However, the connection.create_workitem
method has the relations_raw
parameter that you could use to add links right away.
The code for using relations_raw
should look like this:
existing_wi = TFSAPI.get_workitem(123)
parent_link_raw =
[
{
"rel": "System.LinkTypes.Hierarchy-Reverse", # existing WI will be a parent, new WI will be a child
"url": existing_wi.url
"attributes": {
"isLocked": false
}
},
]
new_wi = TFSAPI.create_workitem("Task", parent_link_raw)
This is a temporary solution as we are yet to implement adding "normal" links, attachments and now raw JSON, but it should work.
@SAnCherepan I actually tried what you suggested and it doesn't seems to work. Here is the error I am getting, could you give me some suggestions? Thanks.
Traceback (most recent call last):
File "tfsfsa.py", line 40, in
Also here is my code,
existing_wi = client.get_workitem(9133) parent_link_raw = [ { "rel": "System.LinkTypes.Hierarchy-Reverse", # existing WI will be a parent, new WI will be a child "url": existing_wi.url, "attributes": { "isLocked":False } }, ] new_wi = client.create_workitem("Task", relations_raw=parent_link_raw)
@ihar512, sorry for the delay.
Troubleshooting steps would be the following:
new_wi = client.create_workitem("Task")
new_wi.add_relations_raw(parent_link_raw)
Let me know if you need any extra info on any of these steps. When both creation and linking work, the whole thing should also work.
@SAnCherepan, I was able to resolve this issue with your suggestion. Thank you!
There doesn't seem to be a clear example in the documentation to assert that a new work item is to be the child of another existing one. How does one do this with the API?