Setting Conditions based on Filed Against
Hi
We are using RTC v5.0
I am trying to create a script that will make two custom attribute fields mandatory when the Filed Against field is set to a certain value, I am using the below script.
dojo.provide("org.example.workitems.providers.category");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.category", null, {
matches: function(workItem, configuration) {
var category= workItem.getValue("com.ibm.team.workitem.attribute.category");
console.log(typeof(category))
return (category === "_ldJ1CuM_EeSNX9RJKvkN6w");
}
});
})();
Could anyone assist please.
Any and all suggestions are most welcome
Kind Regards
Glenn
Accepted answer
You didn't read my answer, or followed any of the links, did you?
You need to use
var category= workItem.getValue(
WorkItemAttributes.FILED_AGAINST
);
or
var category= workItem.getValue(
"category"
);
To read the filed against attribute. As mentioned in https://jazz.net/wiki/bin/view/Main/AttributeCustomization complex attributes are not really supported and the returned UUID's are not exposed in the UI (well at least not where you would expect them).
You can try to use getLabel() to get the display label,
var categoryLabel= workItem.getLabel(
"category"
);
but it might not work as return value, since these kinds of attributes are not really supported. You either have to know or get the UUID or you can't do anything with them.
Consider reading the linked workshop and the API description carefully, if you want to get your JavaScript scripts working.
One other answer
Read
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of