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

RTC Required attributes for Condition applied for Custom Attributes

We are having the condition script below for some attributes "ASIL Level, Basket, Feature Area, Filed Against, Found In, Occurrence, Priority, Regions, Variant":

dojo.provide("com.example.mandatory");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() 
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.mandatory", null,
{ matches: function(workItem, configuration) 

var PA = workItem.getLabel(WorkItemAttributes.PROJECT_AREA);
var ST = workItem.getLabel(WorkItemAttributes.TYPE);
 
 return (PA=="A" && ST=="Bug")|| (PA=="B" && ST=="Bug") || (PA=="C" && ST=="Bug"); } 
  }); })();

Now we need to add one more condition for project "A" (for all work item type) and apply for only "Brands"
How can we update in the same script?
Even i tried with the script below but it does not work :(
dojo.provide("com.example.gmvcu.mandatory");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() 
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.gmvcu.mandatory", null,
{ matches: function(workItem, configuration) 

var PA = workItem.getLabel(WorkItemAttributes.PROJECT_AREA);
var ST = workItem.getLabel(WorkItemAttributes.TYPE);
if (PA=="A" && ST=="Bug") {
return true;
} else if (PA=="B" && ST=="Bug") {
return true;
} else if (PA=="C" && ST=="Bug") {
return true;
} esle if (PA=="A") {
return true;
}
return false; 
 } 
  }); })();

Could you please help us? What should be the best solution? Should we update in the same script or create new? Thank you for your responses

0 votes

Comments

I do not know if it is possible to answer the question. I would suggest to debug the script. See https://rsjazz.wordpress.com/2022/11/17/debugging-ewm-work-item-attribute-customization-javascript/ how this can be done. As an alternative you could add logging of your script. See the links on our guideline.

Hi Ralph Schoon

Thanks for your response

May be, I didn't frame the question properly . Sorry for that. 

Below is my requirement:

Use case 1: Type=Bug, Project=X , make the attributes attr_1 & attr_2 as mandatory

Use case 2: Type = Bug, Project=Y, make the attributes attr_3 as mandatory

 

Is there a way to handle both these use cases via a single "Conditions" script instead of 2 separate scripts to avoid maintenance issues?



2 answers

Permanent link

Hi Ralph Schoon

Thanks for your response

May be, I didn't frame the question properly . Sorry for that. 

Below is my requirement:

Use case 1: Type=Bug, Project=X , make the attributes attr_1 & attr_2 as mandatory

Use case 2: Type = Bug, Project=Y, make the attributes attr_3 as mandatory

 

Is there a way to handle both these use cases via a single "Conditions" script instead of 2 separate scripts to avoid maintenance issues?

0 votes

Comments
I agree with Ralph - these are two different conditions for two different attributes.

Conditions do not have access to what rules or attributes they are attached to, so there is no way to work out if you're talking about attr_3 inside the condition and hence no way to figure out if you should return true or not. Make them separate conditions - one for attr_1 and attr_2, and one for attr_3


Permanent link

You have 

  1. One condition that is either true or false
  2. A configuration of the condition mapping a set of attributes that are required if the condition is true
Can you have an attribute of the set being mandatory and one being optional?

Condition C, Attributes Aa, Ab
Condition C is true => Aa mandatory, Ab mandatory. 

Or Attribute Aa mandatory => C = true, Ab optional => C=false is a contradiction.

That means no. That are my thoughts. Unless there is something else I am forgetting.

0 votes

Comments

If you have distinct attributes in each project area, it might be possible.

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
× 7,506
× 6,130
× 1,336

Question asked: Jul 24 '24, 12:43 a.m.

Question was seen: 635 times

Last updated: Jul 25 '24, 11:18 p.m.

Confirmation Cancel Confirm