Get the history "text" of a past work item edit - tfs

Say I make a work item in TFS. Then I make a change and update the text in the History tab (then save).
Using the TFS API, how can I get that text?
I would have thought it would have been in the History string for last item in the Revisions collection on the work item. (Because to set the string via the API you can use History on a normal work item.) However, in the Revisions array, all the work items are showing up as having History empty.
Any ideas on how I can get this string?

Check this blog post out: http://blogs.msdn.com/b/aaronbjork/archive/2011/01/10/programmatically-reading-work-item-comments.aspx
It’s a simple operation, but it might not be clear at first unless you discover that you need to loop through the collection of Revisions of the work item in order to view those comments.

You can get any of the basic tfs fields via aaronbjork's link and change it to use
Field f = r.Fields.TryGetById(1); or Field f = r.Fields["Title"]
title = 1
description = 52
the list of names and Ids is in the CoreField enumeration (only for non-custom fields)

Related

run SPD workflow on changes to any field EXCEPT one?

I have a custom list. Each item in the list has 39 fields/columns that need to be filled out and a 40th field that gets filled out by a separate workflow.
I have another workflow that I need to trigger if any of the fields change EXCEPT for one.
Why? Because that field has a custom ID# in it and that field gets populated AFTER the form is submitted. Therefore, there will ALWAYS be a change in the list item. Thus, I need a workflow to trigger when any fields change EXCEPT the one w/ the custom ID#.
Any ideas? Thank you.
No one has been able to answer this but I figured it out myself.
I'm including the answer here in case anyone else ever comes across this and finds it helpful:
Create a new field that you will hide from the your SP list and from NewForm.aspx, EditForm.aspx, and DispForm.aspx.
Using jQuery, populate that hidden field as such: $(":input[Title='fieldName']").val("1");
The using an SPD workflow, check to see if that field = 1. If so, run the workflow. AND at the end of that workflow set the field to 0 - that's important.

Access 2010 form not displaying query

I'm sure this is an easy fix but I can't seem to find it. I just have a form, that will be a subform of another, that needs to display the results of a query.
The query is simple enough, just displays all fields of records that fall between specified dates. The query works great, but when I attach it to the form as its record source it doesn't display the data. I can see the correct amount of record selectors so I know its understanding the query but its as if all fields are hidden!
I have also tried building a query to the forms record source that was simply Select query.* From query. Oddly I have had this working before but I had to specify every field. What I mean is:
Select title From query
Select type From query
Select date From query
...
And so on for all the fields but this seems foolish, can anyone think of what I may be doing wrong?
Thanks in advance!
Edit, forgot to mention I also tried the foolish solution that I mentioned above and it didn't work so its definitely some issue that I'm not seeing, some property that's probably not appropriately set
#sshekhar well its not really code at the moment I'm using Access 2010. I have a form that needs to display a subform that executes this query of displaying records that have a data field that fall between dates specified by the user. The query works and displays the correct records, but the form that it is attached to only shows the record selectors and all the fields appear to be "hidden." I thought it may be one of the form's properties set incorrectly but I checked on the test form from another database that I used and each have what appears to be identical settings. So I'm at a loss!
So it turns out even though I using a query that holds all the fields it will not display the content unless you go to the Add Existing Fields and add all the the fields you want to see. This seems really silly especially when the results in the query but at least its working now.
I had this problem and discovered that having the property DataEntry set to YES will only display new records. From Microsoft Help:
You can use the DataEntry property to specify whether a bound form
opens to allow data entry only. The Data Entry property doesn't
determine whether records can be added; it only determines whether
existing records are displayed. Read/write Boolean.

How can I add text to a work item

We have a few bugs and change requests which have a complicated iteration path. This results in people coming over the team to ask 'Where do we raise items' a lot.
As you can't set a default value for the iteration path in TFS 2010 we think the best solution would be to add a string of text under the field which we can manually update every 7 weeks with the correct area to raise items in.
However TFS doesn't seem to allow just a line of text on its work items as a control. Is there a way to add a line of display text i.e. Not a field you edit, but just to inform those writing the items?
Please note that it needs to be visible at all times, using the tooltip 'help text' field on a control is not enough in this case.
You can use the LabelControl for this purpose.
You can not have a default in the work item for the iteration path, but what you can do is making use or the template url in web access or the work item templates in the power tools to create a work item that is prepopulated with values.
What about a custom field with a display control in read-only? You can give a default value to the field and the "read-only" control prevent other to change it.

How to update certain parts of a form

I'm looking to create a report with similar that has a checkbox next to each row. Each row has some fields that are editable (such as comments). What I'd like is to give the user the ability to check off which rows he/she would like to update by selecting the checkbox next to that row. Then I'd have a save button at the bottom of the form that only updates the rows that have a check box active next to it.
I'm pretty new to rails and web programming in general so any advice/direction you might be able to give me should prove helpful.
A popular way to achieve this is to :
1- All your checkboxes should share the same name.
2- All your checkboxes' values should be the ID of the row/object
3- When you POST the form, only the checked checkboxes are in the POST data. Retrieve those IDS and only update these objects.
For example, your checkbox should be something like :
<%= check_box_tag "row_ids[]", row.id, false, :id => "row_#{row.id}" %>
Then, in your controller :
Row.find(params[:row_ids]).each do |row|
# do whatever you want
end
Well you can do this, but it adds more work for the user: they have to check off multiple checkboxes before hitting Update. It be nicer if they just hit Update and it worked.
The basic idea is you want the user to just click Update and your code only updates records that changed.
What you can do is store (in a hidden field tag) the ID of each row's record. Then when you update, you loop through all rows and you grab (based on the ID stored in the hidden field) the record from the database. Let's say only Comments were editable. Then you can check to see if the comments have actually been changed (like with a simple string comparison) and if they have, update it. If more things are editable, then you can check them too before deciding if you need to update or not.
That is a high level description, but let me know if you want some more implementation details.

Creating and editing my element instead of using `new`

So, basically my 'index' action is a long list of elements output as a table with Rails, each one has a checkbox next to it. These elements are items in a catalog that will be line-items in a quote.
A user can select as many checkboxes as they like, then click a button that says "Create a new Quote" it'll take the items they checked and clone them into a new table so they can edit them as apart of the quote.
The issue I'm having is that when the list is really long, say 6000 records it’s a n awfully long list to load, so I want pagination, BUT! then my checkboxes won’t work, because they will go away if the user changes pages.
Additionally the user has no way of going back to this page to "add" more items to the quote.
My first thought was to create a new element right when they browse to this "index page and essentially have the user editing the quote from the get go"
Any ideas on this implementation? I'm a little stuck on how to get started implementing this.
This is a classic shopping cart type problem. You might want to read up on implementing those in Rails with sessions. Simple example is to use the user's session. You can either create a class to encapsulate the logic, or just use a hash or array to hold the ids that are checked. So when the user clicks on "Start New Quote" you can set a var in their session to blank like:
session[:new_quote_items] = []
Then when they check off items you can have a link to add them to the quote. You can then place those ids into the array. On page display of the possible quote items you can show the user which ones are check and have then add/remove IDs from this list. Then when the user is done they can click on a finish link which will take the ids from the session and create the quote as you have now.
This question is similar to yours and covers your first problem. Pagination.
In addition to that, clever use of accepts_nested_attributes_for on the join model will allow you to simplify addition of elements to either existing or new quotes.
Sorry I've got no code for you right now, but here is the general idea:
Generate a list of QuoteItems that is is the union of the set of existing quote items for this quote, and quote items built for the current quote from items not part of the current quote.
Give that list to fields_for and set up each field_for region so that it passes the item_id as a hidden value and contain a checkboxes, such that they modify the :_delete field, with default value evaluating true, and checked value equating to false.

Resources