RTC custom work item script-based validator for unique value
I need to identify a method of ensuring a unique value in a small string attribute of a custom work item within Rational Team Concert (RTC). Ideally, the simplest solution, such as a database column constraint, would be best. However, a script-based validator for the attribute would be acceptable as well. If a script-based validator is the best or only method to accomplish this desired action the actual code to implement this solution would be helpful.
Accepted answer
Script-based validators are based on, JavaScript. I would imagine it is painfully slow if you implement it this way. To ensure the uniqueness, you will have to retrieve all existing work items and compare the intended value with the existing values, which can take a long time.
A database unique index may not be easy to implement either because you cannot map the work item type to a table and the attribute to a column. Even you can somehow implement it, how to handle the database exception is another question - you want to capture the exception and throw a new error with your own message telling the users what's happening.
How should this unique value look like? Does a timestamp (in milliseconds) meet the requirement?
Comments
Unfortunately, a timestamp (in milliseconds) would not meet the requirement. I understand your response that since the JavaScript would need to "retrieve all existing work items and compare the intended value with existing values..." and that this would be time consuming. Based on this information we'll not expend any more effort on using a script-based validator for the purpose of preventing a duplicate attribute value from being entered. Instead, maybe we'll just attempt to train our users to look for the existence of the value before entering a new work item. Thanks for the response.