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

Possible to enforce subcategory selection?

We are using RTC Version 5.0.2, and "Filed Against" is a mandatory attribute.

Picture the following scenario:

root(unassigned)
       ->ParentCat
               ->ChildCat1
               ->ChildCat2

Is it possible to enforce selection of one of the Child Categories here? I know not allowing selection of the parent category defeats the purpose of having the parent category at all but it would make life easier :)

0 votes



One answer

Permanent link
It should be quite easy to do with a validator (attribute customization). Just read the value of the attribute and test with the two child categories, and return true or false accordingly.

0 votes

Comments

JavaScript: How would you test for the category to be a leaf or not? The only information you have is the label and the value and no API to look into the category tree.

Java: Yes, you could use a validator, but that needs to be deployed on clients and servers.

A work item save precondition only needs to be deployed on the server so it might be a better approach. It lacks the user guidance though.

1 vote

Thanks Ralph. Since it is only a single node category that I am concerned with, would the javascript work with a hardcoded label check?

I think you have to try out what you get for workItem.getLabel( WorkItemAttributes.FILED_AGAINST ) and workItem.getValue( WorkItemAttributes.FILED_AGAINST )and if you can use any of that to decide.

yay I got it working with a validation script:

validate: function(attribute, workItem, configuration) {
       
        var category = workItem.getValue(attribute);
       
        if(category == "[category_id]"){
          return new Status(Severity["ERROR"], "Validation failed");
        }

return Status.OK_STATUS;

        }


For a more general case of blocking all category nodes - the getLabel function returns a string with three spaces pre-pended per level (e.g. subCat1 has three spaces before the title, subCat2 has 6 spaces before the title). However of course this would only be relevant / useful if you have just 2 levels of categories

example:

validate: function(attribute, workItem, configuration) {
       
        var category = workItem.getLabel(attribute);       
        var substring = "   ";
        var ind = category.indexOf(substring);
        if(ind != -1){
          return new Status(Severity["ERROR"], "Validation failed - you can not choose parent category: ".concat(category));
        }

return Status.OK_STATUS;

        }

showing 5 of 6 show 1 more comments

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,121
× 32

Question asked: Apr 08 '16, 12:13 p.m.

Question was seen: 3,145 times

Last updated: Apr 15 '16, 3:43 p.m.

Confirmation Cancel Confirm