It's all about the answers!

Ask a question

I want to dynamically make an attribute required when another attribute is null using conditions


John Atari (111) | asked Jun 16 '16, 9:52 p.m.
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
 
    }
});
})();

Comments
John Atari commented 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;
    }
});
})();

One answer



permanent link
Donald Nong (14.5k414) | answered Jun 16 '16, 11:38 p.m.
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:

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?


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


Register or 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.