none
How to set "CreatedBy" value when creating a workItem in Team Foundation Server ?

    Question

  • Hi All,

    I'm using TFS API in my Console Application.

    Here is the code snippet of openning a bug in my work.

    TeamFoundationServer tfs = new TeamFoundationServer(myUrl);
    
    WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
    Project project = store.Projects[myProjectName];
    WorkItemType workItemType = project.WorkItemTypes["Bug"];
    WorkItem workItem = new WorkItem(workItemType);
    workItem.Title = "Test";
    workItem.Description = "Test Open Bug";
    //Set value for other fields...
    workItem.Save();

    And here is a question,:

    In my work, all the bugs get CreatedBy == myName.

    But in fact,  I want to set different CreatedBy value for different branch. And it is impossible to change this directly since the Created by field of the work item is a read only field.

    So, I wonder if there is other solution for my problem.

    Thanks!

    jeudi 26 avril 2012 09:25

Toutes les réponses

  • Hi,

    What you could do is to close the connection and open it again with that other user that you want to use for another branch and then create WI's. In that case you'll get the Created By filed filled with the name/account that you want.


    Please remember to mark the replies as answers if they help. --- Success, Damir

    jeudi 26 avril 2012 09:36