It's all about the answers!

Ask a question

Setting Conditions based on Filed Against


Glenn Watkins (88245) | asked May 03 '16, 7:55 a.m.
 Hi 

We are using RTC v5.0

I am trying to create a script that will make two custom attribute fields mandatory when the Filed Against field is set to a certain value, I am using the below script.

dojo.provide("org.example.workitems.providers.category");

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.category", null, {

    matches: function(workItem, configuration) {
        var category= workItem.getValue("com.ibm.team.workitem.attribute.category");
        console.log(typeof(category))
        return (category === "_ldJ1CuM_EeSNX9RJKvkN6w"); 
    }
});
})();

Could anyone assist please.

Any and all suggestions are most welcome

Kind Regards
Glenn

Accepted answer


permanent link
Ralph Schoon (63.1k33646) | answered May 04 '16, 4:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 04 '16, 5:19 a.m.
 You didn't read my answer, or followed any of the links, did you? 

You need to use 
 var category= workItem.getValue( WorkItemAttributes.FILED_AGAINST );

or

var category= workItem.getValue( "category"  );

To read the filed against attribute. As mentioned in https://jazz.net/wiki/bin/view/Main/AttributeCustomization complex attributes are not really supported and the returned UUID's are not exposed in the UI (well at least not where you would expect them). 

You can try to use getLabel() to get the display label,

 var categoryLabel= workItem.getLabel( "category"   );

 but it might not work as return value, since these kinds of attributes are not really supported. You either have to know or get the UUID or you can't do anything with them. 

Consider reading the linked workshop and the API description carefully, if you want to get your JavaScript scripts working.
Glenn Watkins selected this answer as the correct answer

Comments
Glenn Watkins commented May 06 '16, 2:16 a.m.

 Hi Ralph


Many thanks for your time and patience with this, the method:

var category=workItem.getValue("category");
worked. I used the attributes UUID which I obtained through running the cognos reports. 

Kind Regards
Glenn

One other answer



permanent link
Ralph Schoon (63.1k33646) | answered May 03 '16, 9:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 03 '16, 9:24 a.m.
 Read 
  Lab 5 use loggign to print the data into the logs. Make the script less compact to be ale to print more data. Read the API description. E.g. https://jazz.net/wiki/bin/view/Main/AttributeCustomization .

I am pretty sure your value of 


        var category= workItem.getValue("com.ibm.team.workitem.attribute.category");

is null or a blank string, because the JavaScript API can't work with the external attribute ID that the Eclipse client shows due to a reported bug since various versions. For internal attributes, You need to use the ID's as shown in the Web UI or in the API description (the constants provided in the API) 
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of 

Comments
Glenn Watkins commented May 04 '16, 4:04 a.m.

Hi Ralph


Our design here is that we have a Master Project Template and all "Child" projects use it's process.
This results in different UUID's created for each individual project areas "Filed Against" values, the naming values are the same in the project areas but they have different UUID's, I was of the impression that by extracting the UUID it could be used in a script? 

I have used the skeleton of the above script for enabling behavior when it comes to field attributes on a work item, but the "Filed Against"  attributes do not respond. 

The value "category" is the Web UI displayed ID value for the "Filed Against" attribute and the "_ldJ1CuM_EeSNX9RJKvkN6w" is the UUID for the value I need to instantiate the behavior, these UUID's are not defined in the Process Configuration Source tab, I had to run cognos reports to get them.

Kind Regards
Glenn

Your answer


Register or 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.