It's all about the answers!

Ask a question

Whats wrong with this script?


Pravin Patil (104138133) | asked May 04 '15, 7:24 p.m.
edited May 05 '15, 1:05 p.m. by Ralph Schoon (63.1k33645)

I want to make the field (Name="Release Note Description", ID="release_note_description") to be mandatory if the value in (Name="Release Note Required", ID="release_note_required") is set to "Yes". The literals are "Select a value, Yes, No). I have the following script, but it doesn't work. Please suggest:

dojo.provide("org.example.workitems.providers.ReleaseNote");
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.ReleaseNote", null, {
    matches: function(workItem, configuration) {
      var relnote =  workItem.getValue(WorkItemAttributes.RELEASE);
      return (relnote === "release_note_required.literal.l2"); // Yes
    }
  });
})();


Comments
Don Yang commented May 04 '15, 7:36 p.m.

relnote === "release_note_required.literal.l2" seems to the problem
it should be relnote == "release_note_required.literal.l2"


Pravin Patil commented May 04 '15, 8:01 p.m.

Tried relnote == "release_note_required.literal.l2" and it didn't help.

Does type matter?

The "Release Note Description" is of "Large HTML" type, and "Release Note Required" is "Enumeration"?

Cant think of anything else.

Please suggest.


Don Yang commented May 04 '15, 9:21 p.m.

you can try to debug the script and see if the return value is expected or not by using

console.log()
in the script to print the return value, see more details here:
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Debugging_scripts

If the value is expected, it means the script itself(syntax wise) is correct. If then the mandatory field is not set based on the return value, it could be configuration or logic issue and you need to look into it, you can provide more details on how you did that in your environment to link the return value to the mandatory field.





Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered May 05 '15, 2:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 05 '15, 2:43 a.m.

I would suggest to carefully read https://jazz.net/wiki/bin/view/Main/AttributeCustomization and also https://jazz.net/library/article/1093 and maybe do the workshop.

1. As listed in https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of there is a list of built in attribute ID's you can use. Do you find WorkItemAttributes.RELEASE NOTE REQUIRED or WorkItemAttributes.RELEASE in the list? No, you don't. If you created a custom attribute, you have to pass the ID of the attribute to get to its value. E.g var relnote =  workItem.getValue("the.id.i.gave.the.custom.attribute");would do the trick. In your case this should be correct: var relnote =  workItem.getValue("release_note_required");
2. Be aware that there are limitations mentioned in the links above. You can access enumerations, strings and the like but some value types are not supported.
Pravin Patil selected this answer as the correct answer

Comments
Pravin Patil commented May 05 '15, 11:50 a.m.

I have never done scripting hence will take some time, let me give a try to the links you provided...


Ralph Schoon commented May 05 '15, 1:05 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please, please, please read the links provided in the answers and comments carefully. Especially the workshop - and especially the first two chapter with the limitations. We are explaining these things here over and over. User think this is just scripting - should be simple. It is not and the API limitations are so tight that you will run into them. They are explained. Read them carefully. I don't want to have to explain you can't access attachments in scripts over and over again. Thanks!

PS: google this site for scripting questions - should most be tagged with attribute-customization.


Pravin Patil commented May 05 '15, 2:18 p.m.

Sure, will do.

Is there a reference script for hiding/unhiding a workitem presentation "section" based on a value of enumeration?

Btw, your suggestions of workItem.getValue("the.id.i.gave.the.custom.attribute"); worked. Thanks!!!


Ralph Schoon commented May 06 '15, 2:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

There is no hide on condition as far as I know. RTC is really not designed to hide data, it is designed to share data. There have been requests for this, but as far as I can tell it is not there yet. also please note that hiding happens on the presentation layer in the work item editor. It does not happen in the values in queries as far as I can tell.


Pravin Patil commented May 06 '15, 5:59 p.m.

I have repetitive fields, not of all of them are required to be visible at same time. Once a "Team Impacted 1" section is filled, then "Team Impacted 2" should show up and so on.

Any suggestions...

2 other answers



permanent link
Uma venkata Lekkala (52519) | answered May 07 '15, 7:04 p.m.
edited May 07 '15, 7:05 p.m.
 Can someone help me with a script to Setvalue to two of the attributes based on the value of another attribute (gettext)? I did lot of such coding in CQ where fields are automatically updated, turn mandatoryor drop downs narrowed down based on other field selection state change, user role etc. Can the same language (VB) be used in RTC? 

permanent link
Donald Nong (14.5k414) | answered May 04 '15, 10:23 p.m.
edited May 04 '15, 10:24 p.m.
If I read your codes correctly, you get the wrong attribute for the comparison.
var relnote =  workItem.getValue(WorkItemAttributes.RELEASE); 
Shouldn't you use the attribute "Release Note Required"? 

P.S. It's always helpful to say exactly what the issue rather than "it doesn't work".

Comments
Pravin Patil commented May 05 '15, 12:20 a.m.

 Sure, when I say it doesnt work, I meant that the field "Release Note Description" was not turning into mandatory, after selecting the literal = yes for  enumeration "Release Note Required".


Yes, I tried with var relnote =  workItem.getValue(WorkItemAttributes.RELEASE NOTE REQUIREd);
but it didnt work either...


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.