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

Setting Conditions based on Filed Against

 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

0 votes


Accepted answer

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

0 votes

Comments

 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
 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 

0 votes

Comments

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 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
× 10,938

Question asked: May 03 '16, 7:55 a.m.

Question was seen: 1,823 times

Last updated: May 06 '16, 2:16 a.m.

Confirmation Cancel Confirm