c# 4.0 - Return newly created TFS work item ID using TFS API? -


using tfs api, able create tfs item, no problem.

what best way me know item id newly created item?

thank you,

george

        try         {             // authenticate user account             networkcredential account = new networkcredential(username, password, domain);             // user stories team project user story created.             uri collectionuri = new uri(tfsuri);             //tfsteamprojectcollection tpc = new tfsteamprojectcollection(collectionuri);             tfsteamprojectcollection tpc = new tfsteamprojectcollection(collectionuri, account);             workitemstore workitemstore = tpc.getservice<workitemstore>();             project teamproject = workitemstore.projects[info.tfsprojectname];             workitemtype workitemtype = teamproject.workitemtypes[info.itemtype];             // create work item.              workitem userstory = new workitem(workitemtype);             userstory.title = info.title;             userstory.description = info.description;             userstory.areapath = info.areapath;             userstory.iterationpath = info.iterationpath;             userstory.fields["assigned to"].value = info.assignedto;             if (info.itemtype == "task")             {                 userstory.fields["discipline"].value = info.discipline;             }             else if (info.itemtype == "bug")             {                 userstory.fields["symptom"].value = info.symptom;                 userstory.fields["steps reproduce"].value = info.stepstoreproduce;             }             else if (info.itemtype == "change request")             {                 userstory.fields["justification"].value = info.justification;             }             // save new user story.             userstory.save();             return true;         }         catch (exception ex)         {             log.error("error creating tfs task.", ex);             return false;         }                 {         }     } 

as save userstory, id field populated. should able return userstory.id.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -