I want to dynamically make an attribute required when another attribute is null using conditions
![](http://jazz.net/_images/myphoto/07c2be19fb8571848ed8f0d093c3d187.jpg)
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
}
});
})();
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
![](http://jazz.net/_images/myphoto/07c2be19fb8571848ed8f0d093c3d187.jpg)
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
http://stackoverflow.com/questions/2559318/how-to-check-for-an-undefined-or-null-variable-in-javascript
Comments
![](http://jazz.net/_images/myphoto/07c2be19fb8571848ed8f0d093c3d187.jpg)
Thank you for your response Donald. If I am reading that correctly I need to change var result to the following line:
var result = sev (typeof("") != 'undefined' && "" != null);
//it is a type string, if that is undefined or if the string itself is undefined, consider the value null?
![](http://jazz.net/_images/myphoto/0227396f4efb17d0baa0c12dd70df878.jpg)
I have no idea why you came up with such code - it's static. I thought you should test the variable "subTeam", no?
Comments
John Atari
Jun 16 '16, 10:39 p.m.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;
}
});
})();