I want to dynamically make an attribute required when another attribute is null using conditions
I am trying to make a work item attribute required when another attribute has no value. I have tried many different ways to return the null value but haven't had any luck. I am a student and new to RTC, any help would be appreciated. I have provided the code I am using below. Thank you in advance!
dojo.provide("org.example.workitems.providers.newAttributeCondition"); dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; dojo.declare("org.example.workitems.providers.newAttributeCondition", null, { matches: function(attributeID, workItem, configuration) { var RCAppID= (workItem.getValue("newAttribute") //newAttribute is the attributeID return (RCAppID !=== null) //if id newAttribute is not null, attribute is required } }); })(); |
One answer
So your question is actually how to detect whether a value is null, undefined or empty in JavaScript. If really depends on what the type of attribute "rootCauseApp" is. For a general discussion on this topic, check out this port on StackOverflow.
http://stackoverflow.com/questions/2559318/how-to-check-for-an-undefined-or-null-variable-in-javascript Comments
John Atari
commented Jun 17 '16, 7:35 a.m.
Thank you for your response Donald. If I am reading that correctly I need to change var result to the following line:
Donald Nong
commented Jun 19 '16, 9:15 p.m.
I have no idea why you came up with such code - it's static. I thought you should test the variable "subTeam", no?
|
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.
Comments
I have updated my script to this with still no avail:
dojo.provide("org.example.workitems.providers.SubTeamRequired")
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.SubTeamRequired", null, {
matches: function(workItem, configuration) {
var subTeam= (workItem.getValue("rootCauseApp"));
var result = subTeam !=== "";
return result;
}
});
})();