views:

22

answers:

1

I have a web system that has a few hooks into our TFS work item system. One of the things I am trying to do is that when a certain action is performed, it takes the current text in one field and makes a comment in the "General Comments" field announcing what the field was previously (Yes I know, history contains this but the higher ups want this in the gen comments).

The problem I am having is that TFS seems to be ignoring Environment.NewLines that I have in my string. So with this code:

                    item.Fields[GENCOMMENTS].Value = string.Concat(DateTime.Now.ToShortDateString()
                                , " - QA Dashboard - Required By Date Reason set to \"Hotfix\", but previously contained \""
                                , item.Fields[REQBYDTREASON].Value.ToString()
                                , "\"."
                                , Environment.NewLine
                                , Environment.NewLine
                                , Environment.NewLine
                                , item.Fields[GENCOMMENTS].Value.ToString());

So assuming my general comments section contains:

THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

I get the following output in the general comments section when the work item is saved

9/29/2010 - QA Dashboard - Required By Date Reason set to "Hotfix", but previously contained "hotfixtest".THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

Why is it ignoring the new lines and how can I get a new line into the work item?

Thanks,

+1  A: 

TFS work item content is often processed as HTML. That's likely happening here and hence it's ignoring the extraneous newlines in the text. Try wrapping the content in a <pre> block or using <p> and see if that fixes the issue.

JaredPar
Aha that explains it. Using `<br>` worked as well :)
KallDrexx