Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



One answer

Permanent link
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.

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,132

Question asked: Feb 24 '16, 5:44 p.m.

Question was seen: 2,461 times

Last updated: Feb 25 '16, 5:27 a.m.

Confirmation Cancel Confirm