Whats wrong with this script?
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
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
}
});
})();
Accepted answer
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
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.
Comments
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
I have never done scripting hence will take some time, let me give a try to the links you provided...
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
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.
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
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!!!
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
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.
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
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
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
var relnote = workItem.getValue(WorkItemAttributes.RELEASE);
Comments
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
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".
![](http://jazz.net/_images/myphoto/3e255ee704d5c532e320263c06279468.jpg)
Comments
Don Yang
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
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
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
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.