Setting an attribute value from script
Hello Guys,
I am trying to make few fields read only based on condition. I can do it by settting up 'Operational Behaviour' in the project area. Apart from this, before settting up the values read only, i should also be able to set the value to zero. Is it possible to set the value from a js script before setting it to read only. Belwo is the script.
dojo.provide("net.jazz.example.readonly.Condition");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("net.jazz.example.readonly.Condition", null, {
matches: function(workItem, configuration) {
var dropdownvalue = workItem.getValue("dropdown");
console.log("HERE IS THE VALUE" + " " + dropdownvalue);
if (dropdownvalue=="inex.literal.l4")
return true;
}
});
})();
Thanks..Johnson
3 answers
along with your condition, you may want to use default value attribute customization to set the default.
Comments
One part is already taken care by your script.
To make the attributes mandatory, in the Attribute Customization section you can add a script based Validation which will check if the attribute values are null and then add Attribute Validation precondition from the Operation Behavior section. ( you can find further help in https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_Based_Validation)
Now, your comment "In another scenario...." is something sounds contradictory to me. On one hand you are saying that if the value is Exclude then the other attributes will be "readonly" whereas you are trying to change or set the value to 0. May be something to think of if a different approach is easier; however, you can try this with Script based Calculated Values.