Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes


Accepted answer

Permanent link
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;

        }
    });
})();
PRASANTA CHAUDHURI selected this answer as the correct answer

0 votes

Comments

Thanks Brian

This has worked very nicely.

If you have some more scripts , Request your posting or let me know the URL

Regards

PKC

Prasanta Kumar Chaudhuri

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,130

Question asked: Dec 22 '14, 2:20 p.m.

Question was seen: 2,397 times

Last updated: Dec 23 '14, 3:37 a.m.

Confirmation Cancel Confirm