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

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

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");
        }

    });
})();

0 votes



One answer

Permanent link
use the attributes ID

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

1 vote

Comments

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.

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 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

Question asked: May 12 '14, 9:27 a.m.

Question was seen: 4,159 times

Last updated: May 15 '14, 3:50 p.m.

Confirmation Cancel Confirm