RTC 6.0.1 make required attribute depending of the previous values?
How can I make required attribute depending of previous values selected in other(s) attributes
|
One answer
Basically you can just use the condition script of the attribute customization combined with the Required Attributes For Condition precondition. Since you mentioned "previous values", which I understand are the "saved values", you will need some tweaks for it to work - you need to ensure the script only evaluates the "saved values".
Here is the sample code that I quickly write. Of course you need to do your own testing to accept it. dojo.provide("com.example.RequiredByOthers"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // Define non-local variables var com_example_RequiredByOthers_WIs; var com_example_RequiredByOthers; (function() { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("com.example.RequiredByOthers", null, { matches: function(workItem, configuration) { // Create the key pair collection if not exists yet if ((typeof com_example_RequiredByOthers_WIs) == "undefined") { com_example_RequiredByOthers_WIs = new Object(); } var id = "" + workItem.getValue(WorkItemAttributes.ID); // Force a string instead of int var modified = workItem.getValue(WorkItemAttributes.MODIFIED); if ((com_example_RequiredByOthers_WIs[id] == modified) && ((typeof com_example_RequiredByOthers) != "undefined")) { // the existing data has been evaluated before, return the existing value return com_example_RequiredByOthers; } else { // Not required by default com_example_RequiredByOthers = false; // Save the current state of the WI com_example_RequiredByOthers_WIs[id] = modified; // Do necessary checking against existing values and assign true or false accordingly. // return com_example_RequiredByOthers; } } }); })(); P.S. The script will be executed when the work item is loaded, and every time an attribute is changed. The two non-local variables provide a way to execute the script only when the work item is loaded, or when the work item is saved. |
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.