none
How to set non-Core properties on Work Items?!

    Soru

  • All,

    I'm using the Java SDK 10-1-0 and I can create Work Items successfully (as 'Bug' types), as per the snippet examples.

    What I cannot see how to do however is to set extended properties on this bug, eg, Priority & Severity. I would also like to be able to have the 'description' information displayed in the 'Detail' panel within TFS.

    Does the API allow for this? If not, is there another approach I should be taking for setting these properties?

    Thanks,

    Chris

    21 Şubat 2012 Salı 17:52

Yanıtlar

  • Ok, I've worked this out now.

    To get a complete list of available fields for a work item you can use this code:

    for (Field fieldDefinition : newWorkItem.getFields())
    {
    System.out.println(fieldDefinition.getReferenceName() + "[" + fieldDefinition.getName() + "]");
    }

    And from there, updating specific fields is a case of referencing the fieldDefinition.getName() field name.

    What I don't understand is why only some of these fields are listed in the CoreFieldReferenceNames list. Presumably they aren't deemed 'Core'?

    Anyway, for my specific issue this has got me over the hump.

    eg:

    // Update priority
    newWorkItem.getFields().getField("Priority").setValue(params.getPriority());
    // Update severity
    newWorkItem.getFields().getField("Severity").setValue(params.getSeverity());
    // Add reproduction detail
    newWorkItem.getFields().getField("Repro Steps").setValue(params.getDescription());

    22 Şubat 2012 Çarşamba 09:34

Tüm Yanıtlar

  • Ok, I've worked this out now.

    To get a complete list of available fields for a work item you can use this code:

    for (Field fieldDefinition : newWorkItem.getFields())
    {
    System.out.println(fieldDefinition.getReferenceName() + "[" + fieldDefinition.getName() + "]");
    }

    And from there, updating specific fields is a case of referencing the fieldDefinition.getName() field name.

    What I don't understand is why only some of these fields are listed in the CoreFieldReferenceNames list. Presumably they aren't deemed 'Core'?

    Anyway, for my specific issue this has got me over the hump.

    eg:

    // Update priority
    newWorkItem.getFields().getField("Priority").setValue(params.getPriority());
    // Update severity
    newWorkItem.getFields().getField("Severity").setValue(params.getSeverity());
    // Add reproduction detail
    newWorkItem.getFields().getField("Repro Steps").setValue(params.getDescription());

    22 Şubat 2012 Çarşamba 09:34
  • You got it.  The "Core" fields are the ones in all work items, things like what Team Project the work item is for etc.  Things like Priority, Severity etc are all dependent on the particular process template being used for that Team Project.  Indeed, core fields like Title or Description might even be not populated in some process templates.

    The huge degree of flexibility that customers have over their process templates is one of the major benefits of TFS - however it can make making generic code that works against all process templates a bit of a challenge.


    http://www.woodwardweb.com

    22 Şubat 2012 Çarşamba 10:07