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?