How to add a default Text in a customized field
How to add a default Text in a customized field followed by Task ID , everytime while creating a work item.
Example -- After submitting new task , on save the customized field will show text like "PRNT-Task000231".
where PRTN- is the default Text , Task is the Type of the workitem getting created and 000231 is the ID of the workitem being created .
Request your help and details on how to do it.
Thanks & Regards
PKC
Example -- After submitting new task , on save the customized field will show text like "PRNT-Task000231".
where PRTN- is the default Text , Task is the Type of the workitem getting created and 000231 is the ID of the workitem being created .
Request your help and details on how to do it.
Thanks & Regards
PKC
Accepted answer
Create a Script Based Calculated Value and associate it with your custom attribute. A sample script is below. Note that workItem.getValue(WorkItemAttributes.TYPE) returns the id of the workitem type so you will need to map these to the workitem type name within your script as I have done for defect and task.
/*******************************************************************************
* 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.test");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.test", null, {
getValue: function(attribute, workItem, configuration) {
var type = workItem.getValue(WorkItemAttributes.TYPE);
if (type == "defect") {
type = "Defect";
} else if (type =="task") {
type = "Task";
}
var id = workItem.getValue(WorkItemAttributes.ID);
var state = workItem.getValue(WorkItemAttributes.STATE);
if (!state) return ""; //returns an empty string prior to workitem being saved
return "PRNT: " + type + id;
}
});
})();
/*******************************************************************************
* 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.test");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.test", null, {
getValue: function(attribute, workItem, configuration) {
var type = workItem.getValue(WorkItemAttributes.TYPE);
if (type == "defect") {
type = "Defect";
} else if (type =="task") {
type = "Task";
}
var id = workItem.getValue(WorkItemAttributes.ID);
var state = workItem.getValue(WorkItemAttributes.STATE);
if (!state) return ""; //returns an empty string prior to workitem being saved
return "PRNT: " + type + id;
}
});
})();