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

Whats wrong with this script?

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

0 votes

Comments

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

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.

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

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

0 votes

Comments

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

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.

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!!!

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.

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
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".

0 votes

Comments

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


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

0 votes

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

Question asked: May 04 '15, 7:24 p.m.

Question was seen: 2,965 times

Last updated: May 07 '15, 7:05 p.m.

Confirmation Cancel Confirm