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

Java Script Validator for Category type Attribute not working

I am using RTC 6.0.3 server.  There is a problem with a validator script that is trying to prevent the selection of the top two tiers of a Category type attribute.  The problem is that on the display the little red "!" icon appears on the display when the user selects the TOP category or the NEXT category (as expected) but when the user clicks the Save button, only the TOP category is blocked.  The work item is able to be saved with the NEXT category even though after the save the red "!" icon is still marking the attribute on the display. 

Code is As follows for the validate function of the validator script:

validate: function(attribute, workItem, configuration) {
   var category = workItem.getLabel(attribute);
   var CAT_TOP = "Project Name";
   var CAT_NEXT = "Teams";
   if ((category == CAT_TOP) || (category == CAT_NEXT))
      return new Status(Severity[Severity.ERROR.name], "Select a Valid Team");
   return Status.OK_Status;
}

A workaround that seems to work is to use the UUID of the invalid categories:
   var category = workItem.getValue(attribute);
   var CAT_TOP = "_XXXXXXXX";
   var CAT_NEXT = "_YYYYYYYY";

Using the browser debugging capabilities to step through the code shows that whether I am using the getValue or getLabel configuration there is no change in how the validator script works. 

I don't like to hard-code UUID's in the java script because the UUID is different from project to project and the script has to be modified to put this on the production project after developing and testing the script on the test project. 

0 votes

Comments

If I don't "Accept" any answers, it means I don't have the rank on this forum to give it a thumbs down yet.   



One answer

Permanent link

 It is possible to make attribute customization scripts configurable. It basically uses the same information format that the attribute customization use in general.



This avoids hard coding.

You might also want to try to use Chrome to debug the scripts to better understand the values you are getting.
Finally, check for the equal operator for JavaScript e.g. === vs. == which might or might not contribute to your issue.

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
× 11,089
× 153

Question asked: Dec 14 '18, 1:26 p.m.

Question was seen: 4,582 times

Last updated: Jun 13 '19, 8:14 p.m.

Confirmation Cancel Confirm