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

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
 
    }
});
})();

0 votes

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;
    }
});
})();



One answer

Permanent link
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

0 votes

Comments

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?

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 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
× 4

Question asked: Jun 16 '16, 9:52 p.m.

Question was seen: 2,767 times

Last updated: Jun 19 '16, 9:15 p.m.

Confirmation Cancel Confirm