It's all about the answers!

Ask a question

JavaScript condition based on value of custom attribute?

Susan Hanson (1.6k2185193) | asked Aug 06 '13, 6:43 a.m.
I'm doing a JavaScript-based condition to be used to determine dynamically if an attribute should be required, based on

We want a custom String field (Submitter phone) to be required whenever a custom Integer field (DevWorksID) is equal to 0.

I've looked in a couple other places:

and everything seems to only work off built-in attributes.
Is this possible?  I'm on 4001.


Accepted answer

permanent link
Indradri Basu (1.8k1514) | answered Aug 06 '13, 7:17 a.m.
Yes, I have tried conditions with custom attributes and it worked for me.
Here is a dummy script:

(function() {
    dojo.declare("com.example.Condition", null, {
        matches: function(workItem, configuration) {

         var DWID = workItem.getValue("DevWorksID");
         console.log("HERE IS THE VALUE" + " " + DWID);
          if (DWID=="0") {
            return true;
        else  {
            return false;
Then from Operations Behavior-> Save WorkItems, add the precondition "Required Attribute for Conditions"  and add your new condition for the required attribute(s).

Susan Hanson selected this answer as the correct answer

Susan Hanson commented Aug 06 '13, 7:18 a.m.

oh geez, now i feel a little silly :-)

Thanks so much!

Your answer

Register or to post your answer.