JavaScript condition based on value of custom attribute?
I'm doing a JavaScript-based condition to be used to determine dynamically if an attribute should be required, based on
https://jazz.net/library/article/1003/#conditions
We want a custom String field (Submitter phone) to be required whenever a custom Integer field (DevWorksID) is equal to 0.
I've looked in a couple other places:
https://jazz.net/wiki/bin/view/Main/AttributeCustomizationExamples#Determine_the_value_set_for_an_e
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Conditions
and everything seems to only work off built-in attributes.
Is this possible? I'm on 4001.
Thanks,
Susan
https://jazz.net/library/article/1003/#conditions
We want a custom String field (Submitter phone) to be required whenever a custom Integer field (DevWorksID) is equal to 0.
I've looked in a couple other places:
https://jazz.net/wiki/bin/view/Main/AttributeCustomizationExamples#Determine_the_value_set_for_an_e
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Conditions
and everything seems to only work off built-in attributes.
Is this possible? I'm on 4001.
Thanks,
Susan
Accepted answer
Yes, I have tried conditions with custom attributes and it worked for me.
Here is a dummy script:
Here is a dummy script:
dojo.provide("com.example.Condition");Then from Operations Behavior-> Save WorkItems, add the precondition "Required Attribute for Conditions" and add your new condition for the required attribute(s).
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
dojo.declare("com.example.Condition", null, {
matches: function(workItem, configuration) {
var DWID = workItem.getValue("DevWorksID");
console.log("HERE IS THE VALUE" + " " + DWID);
if (DWID=="0") {
return true;
}
else {
return false;
}
}
});
})();