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

Condition to make attribute mandatory on the basis of specific State and specific option from drop-down

Hi All,

I need little more help from you guys as i need to make a condition which will make another drop down mandatory in specific state, i have created a script for that but its not giving expected result.

could you please check if there is any mistake in following script, i'll be very much thankful to you.

Scenario: 
There is an attribute(dropdown-1) which has two radio button (Yes / No), two states (FLA & SLA) and there is another attribute (dropdown-2) which in located on other tab 
if user select No from dropdown-1 and workitem reach to the State (FLA or SLA) then on other tab dropdown-2 while become mandatory

Script:
dojo.provide("org.example.workitems.providers.RFCIsaProjectNoFLASLA");
dojo.provide("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("org.example.workitems.providers.RFCIsaProjectNoFLASLA" , null, {
matches: function(attributeId, workItem, configuration){
var state = workItem.getValue("WorkItemAttributes.STATE");
var rfcvalue = workItem.getValue("attribute.rfcisaproject");
console.log(typeof (state));
if(state == "arabbank.workflow.rfcworkflow.state.s5" || rfcvalue == "enumeration.rfcisproject.literal.l3"){
return true;
}
return false;
}
});
})();

0 votes


Accepted answer

Permanent link
when using custom attributes,
var rfcvalue = workItem.getValue("attribute.rfcisaproject");

you need to use the ID of the attribute.. mine are usually 'com.sd.workitemtype.attribute.name'

com.sd.defect.attribute.some_name

var rfcvalue = workItem.getValue("com.sd.defect.attribute.some_name");
Ralph Schoon selected this answer as the correct answer

0 votes

Comments

 sam detweiler Thanks for the prompt response but the ID is correct i have already use the same ID for another condition, also  have define my own naming convention for the attribute ID's


kindly please look into the script again.

Ok, many folks post something slightly different than actual values..

I would add logging to see what u are actually getting for the two values.

also javascript equals is usually '==='

 sam detweiler you mean to say my script is correct i just need to correct  '==='  sign in my script ? right 


if there is any other error in my script then please specify dear

I don't 'see' anything wrong specifically.

I would add console.log() to dump out the values from the two variables to confirm they are as u expect

Hi, Sajjad

It is not clear from the question that What results you have got.

From "if user select No from dropdown-1 and workitem reach to the State (FLA or SLA) ", my understanding is that you wand a 'AND' logic but your script use OR logic
if(state == "arabbank.workflow.rfcworkflow.state.s5" || rfcvalue == "enumeration.rfcisproject.literal.l3")

You may want to have a look at this as well.

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
× 12,015
× 7,488
× 1,699

Question asked: Aug 23 '15, 6:10 a.m.

Question was seen: 3,347 times

Last updated: Aug 23 '15, 7:28 p.m.

Confirmation Cancel Confirm