How can I get workItem Id for a newly created workitem in VSTS
Hi When I create a workitem in a Team project, it calls Save() API and generates a workItem Id for that. How can I get a workitem Id of the newly created workitem. Do we have any API for that or any other solution if anybody have.
The WorkItem.Id that you get from the workitem object that you called Save() on, will be the Id for the object that you saved - we're taking care of potential concurrency issues internally. Are you running into any issues with this
This is what is happening within the WorkItemTracking object model:
When the workitem is saved, a save request is sent to the middle tier. The middle tier makes a sql call that does the actual save, and gets the ID of the added item as part of the batch. The middle tier then returns this ID (and some additional data about the workitem) back to the client, which plugs the new Id back into the workitem object that was used to do the save.
So, unless there is a bug, the Id that comes out of the WorkItem object should be reliable.
Can you please clarify the question and the scenario
On the workitem that was saved, you can get the Id by immediately calling "WorkItem.Id" property.
Are you looking for a different way to get the Id of the workitem, than calling Workitem.Id on the newly created workitem Or are you looking for a way to predict what the Id would be, before calling Workitem.Save
Thanks for your reply. You are right that after calling the save(), we can get the Id of workitem by calling workitem.id. But the problem can occur if at the same time any other person creates a new work item. Because in that situation we will get wrong work item Id.
Regards
How can I get workItem Id for a newly created workitem in VSTS
How can I get workItem Id for a newly created workitem in VSTS
arunvenkata
Hi Neelam,
The WorkItem.Id that you get from the workitem object that you called Save() on, will be the Id for the object that you saved - we're taking care of potential concurrency issues internally.
Are you running into any issues with this
Thanks.
-Mareen.
potter12
This is what is happening within the WorkItemTracking object model:
When the workitem is saved, a save request is sent to the middle tier. The middle tier makes a sql call that does the actual save, and gets the ID of the added item as part of the batch. The middle tier then returns this ID (and some additional data about the workitem) back to the client, which plugs the new Id back into the workitem object that was used to do the save.
So, unless there is a bug, the Id that comes out of the WorkItem object should be reliable.
Thanks.
-Mareen.
Peds
Can you please clarify the question and the scenario
On the workitem that was saved, you can get the Id by immediately calling "WorkItem.Id" property.
Are you looking for a different way to get the Id of the workitem, than calling Workitem.Id on the newly created workitem
Or are you looking for a way to predict what the Id would be, before calling Workitem.Save
Thanks.
-Mareen.
Merovingian
Thanks for your reply.
You are right that after calling the save(), we can get the Id of workitem by calling workitem.id. But the problem can occur if at the same time any other person creates a new work item. Because in that situation we will get wrong work item Id.
Regards