Condition to make attribute mandatory on the basis of specific State and specific option from drop-down
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;
}
});
})();
Accepted answer
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");
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
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
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.