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 typevar type = workItem.getValue(workItemAttributes.TYPE);//get the work item categories//var category = workItem.getValue(com.ibm.team.workitem.attribute.categoryconsole.log(type);//Get the value of the work item's category//var category = workItem.getValue(WorkItemAtrributreturn (type === "workitem") && (field1 === "x") && (field2 === "y");}
});})();
One answer
use the attributes ID
var data = workItem.getValue('attribute_id');
var data = workItem.getValue('attribute_id');