Automatically generated content for particular attribute field
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
Ralph Schoon (63.6k●3●36●46)
| 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.
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
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.