It's all about the answers!

Ask a question

Automatically generated content for particular attribute field


Ciprian Spiridon (3125) | asked Feb 25 '15, 3:48 a.m.
Does anyone know how to create an attribute field that is generating automatically a customized ID?
In example,when a particular work item type is new created I need an automatic field populated with an ID with format STxxxxx which is automatically generated, similar to the Work Item ID but as separate field.

Is this possible?

Thank you.

One answer



permanent link
Ralph Schoon (63.1k33646) | answered Feb 25 '15, 4:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
There are three viable approaches as far as I can tell.

  1. A Custom Editor Presentation that calculates the data from the ID and shows it or stores it in a custom read only string attribute
  2. A JavaScript Based AttributeCustomization for a custom read only string attribute; also see
  3. A follow up Action for a custom read only string attribute; See Rational Team Concert Extensions Workshop and my blog for examples 

All approaches have pro's and con's.

For 2. the script would look like this

/*******************************************************************************
 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2011. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:  
 * Use, duplication or disclosure restricted by GSA ADP Schedule 
 * Contract with IBM Corp. 
 *******************************************************************************/
dojo.provide("com.example.CustomID");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {

var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

    dojo.declare("com.example.CustomID", null, {

        getValue: function(attribute, workItem, configuration) {				
			return "ACME" + workItem.getValue(WorkItemAttributes.ID);
        }
    });
})();
Attachments scripts need to be enabled, the calculated value provider with the script above needs to be bound to the attribute, which needs to be added to all work item types.
The problem is, the ID is only created during the first save. To trigger on the save, I had to add a dependency to the modification date. So the calculation will run always, on any save.

JavaScript is not available if the API is used to create work items, so it would not work for that.

3. Will, if done as a work item save (server) extension, work always, unlike 2. But it will issue a second save after the first one - once - which might trigger additional e-mail notifications.

I can't say too much about 1. If you store it in a attribute, it is fully accessible. If not, I don't know. I have not tried something like this.


Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.