It's all about the answers!

Ask a question

How to utilize custom work item fields for Attribute Customization scripts?


S S (141418) | asked May 12 '14, 9:27 a.m.
edited May 12 '14, 10:26 a.m. by Ralph Schoon (63.3k33646)
I'm trying to write a script for a new condition under the Attribute Customization sub category. I found a a couple of basic js guides but wasn't able to find too much on working with custom work item fields. My goal is to write something that will only allow users to save a work item if certain conditions are met (work item has to be a certain type + a few custom fields have to have certain values). However, I'm unsure how to access these values since I wasn't able to find information on the necessary API.

Here's what I have currently:

(function() {
var doDebug = true;
var scriptname = "SaveCondition";
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.ibm.tap.SaveCondition", null, {

        matches: function(workItem, configuration) {
debug("Start");
//Get the work item type
var type = workItem.getValue(workItemAttributes.TYPE);
//get the work item categories
//var category = workItem.getValue(com.ibm.team.workitem.attribute.category
console.log(type);
//Get the value of the work item's category
//var category = workItem.getValue(WorkItemAtrribut
            return (type === "workitem") && (field1 === "x") && (field2 === "y");
        }

    });
})();

One answer



permanent link
sam detweiler (12.5k6195201) | answered May 12 '14, 9:33 a.m.
use the attributes ID

var data = workItem.getValue('attribute_id');

Comments
S S commented May 15 '14, 2:01 p.m.

Thanks, Sam! I got the value of the fields I wanted to satisfy the above conditions. However, is there anyway to specify that the above conditions should only hold for a certain user role? I'm thinking about creating a separate user role that will only give partial access to certain work items. I.e. Users with this new role will only be able to set the attribute values and save the work item. They won't be able to manually transition it.


sam detweiler commented May 15 '14, 3:50 p.m.

far as I know all the javascript customization scripts fire for all workitems with those attributes defined for all users in all roles.

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.