It's all about the answers!

Ask a question

How to force selection of a Planned For which has not already completed


Ian Wark (79713553) | asked Mar 26 '13, 9:43 p.m.

We are struggling to meet this requirement. Can you help us find a solution? We are thinking it is necessary to create a precondition and do some Java coding, but open to other solutions.

Please note the below unacceptable solutions:

(1) Check "A release is scheduled for this iteration" in the Edit Iteration window from Overview tab of e.g. project area. This causes the iteration to not appear in Planned For listbox.
(2) In [Window] > [Preferences] > [Work Items] > [Hide past iterations] option in Eclipse client. We can't check this works, since there is a defect which does not persist the check made, but we think this causes the iteration to not appear in Planned For listbox.

In either of these cases past iterations can be prevented from appearing in the Planned For list box, but unfortunately if the past iteration is already set in the workitem, when you next save the work item, you will not be told to select a current one.

We tried using a script to achieve this functionality by resetting the contents of Planned For listbox to only current iterations in a Script Based Value Set (https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_Based_Value_Set), but the problem is how to obtain information about plans.. We have the same problem if we try to validate the value that is set in the Planned For list box via a Condition (https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Conditions). We think it would be necessary to call REST API from Javascript, but it is not clear how this might be done. We tried debugging a bit and came up with below.. but I think it would give us XML to parse or something and we do not know how to make such a REST API call from the script.

https://clm.jkebanking.net:9443/ccm/service/com.ibm.team.process.internal.service.web.IProcessWebUIService/iterations?uuid=_Yhu1JYCdEeKdF-x46HcQfA&includeArchived=true

So after that we thought it would be better to approach this with a Custom Operation Advisors. We have found the below article more useful than the RTC 4.0 Extensibility Lab Exercises. Most of the example code is exactly what we need.

Rational Team Concert - Creating Custom Operation Advisors
https://jazz.net/library/article/495

This bit is good for showing the user an error:

IAdvisorInfo problem = collector.createProblemInfo(
    "Old Target", "The target has already finished. Choose a different target. : "
    + sourceworkItem.getWorkItemType(),
    PROBLEM_TYPE);
    collector.addInfo(problem);

If we are correct and the best way to achieve this is a Custom Operation Advisor, could someone tell us how to do the below?

i. How can we obtain plan type information (iterations etc..)?
ii. How can we check what has actually been selected by the user in Planned For list box? We are thinking this might be a REST API call.

I can't find code samples to help with these things.

Accepted answer


permanent link
Ralph Schoon (63.6k33646) | answered Mar 28 '13, 6:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 28 '13, 6:45 a.m.
i. How can we obtain plan/target type information(such as iterations)?
--> We are looking for this because if we could obtain, we could use this information to prepopulate the Planned For list box with targets that have not yet completed.
You should not attempt to modify the UI. You would have to modify all Clients, Web, Eclipse, etc. and that is not feasible and basically too expensive.

ii. How can we check what has actually been selected by the user in Planned For list box? We are thinking this might be a REST API call.
--> If we could check the end date of what the user has selected we could prompt user to select something that is current, and not try to pre-populate the Planned For list box.
Again, you don't do anything with the UI, you create a custom pre-condition  also called advisor for the server WorkItem Save operation (as you suggest in your initial question).

On save you check if the condition (state, WI type etc) to trigger it is given. If so, you would get the planned for (target) attribute of the work item new state, potentially check if it has been changed, against the old state and check if it is completed or not. If the iteration is completed prevent save and create a message why.

See http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/ for code around iterations. This is client code, but the API should be similar in a pre-condition on the server. Only the client libraries need to be replaced with the Services on the server accessible by getService(). For more information see other posts on my blog and  https://jazz.net/library/article/1000 .
Ian Wark selected this answer as the correct answer

One other answer



permanent link
Ralph Schoon (63.6k33646) | answered Mar 28 '13, 4:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 28 '13, 6:01 a.m.
Hi Ian,

this post is confusing me. What do you want to achieve? A good part of the text is clutter and I can't really read it. To answer we need a good description of what you want to achieve.

If I assume you want to prevent completed iterations to be selected for work items in some cases, my answer would be:

  • It needs to have a clear reason and way to detect. I think it would just be an annoyance to prevent saving for example If a past iteration is already selected and the work item is just updated or someone commented on it.
  • Your best chance of achieving this would be using an advisor as you suggest above. JavaScript just does not give you access to the information you require. See http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/ for some example code for accessing iterations using the Java API. You might need to adopt the services/client libraries for its usage in a server extension.
  • "A release is scheduled for this iteration"is required so that you can select an iteration as planned for at all and see it in a plan, so I don't understand that part of the question. See https://jazz.net/library/article/589 for ow things work together.




Comments
Ian Wark commented Mar 28 '13, 5:42 a.m.

Ralph,

Thank you for the response.

I am sorry that the formatting is poor in this post. The URL seems to have included a large chunk of unnecessary text <style> .. </style>. The pre-formatted text at the bottom was only meant for the code but seems to have included the rest as well.
I am afraid it is not my requirement but our client who has requirement to prevent workitem save when an old target is selected. Client wants to prevent save if an old target (iteration etc..) is selected in Planned For. This seems to be a reasonable request. Client certainly does not want to do this to annoy end users. It is to improve quality. The current client is so keen to prevent saving when a target is selected whose date is already in the past that they have removed the check for "A release is scheduled for this iteration". This has the side-effect of removing the target (what ever it was) from the Planned For list box. What they are saying, however, is that by removing a past target from the Planned For list box will not prevent users from having an old target, and is therefore not a complete solution. (Although better than nothing at all.)


Ian Wark commented Mar 28 '13, 5:43 a.m.

Given that we cannot achieve this behaviour without some customization, and given that we cannot achieve this using Javascript.. we are looking for help at coding this in Java. We ask because the APIs are not so straightforward to apply.

If you can help us with a sample code snippet etc.. for the below it would be much appreciated.

i. How can we obtain plan/target type information(such as iterations)?
--> We are looking for this because if we could obtain, we could use this information to prepopulate the Planned For list box with targets that have not yet completed.

ii. How can we check what has actually been selected by the user in Planned For list box? We are thinking this might be a REST API call.
--> If we could check the end date of what the user has selected we could prompt user to select something that is current, and not try to pre-populate the Planned For list box.

I hope that this makes more sense.


Ralph Schoon commented Mar 28 '13, 5:57 a.m. | edited Mar 28 '13, 6:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi Ian,

use the pre html tag to insert code like here:

  Preformatted code that has been pasted out of some editor
Use the "View HTML source" button (top right button) to add the tag.

I already provided you with hints on the API in my original answer. As far as I can tell, you can only access the data using the Java API, like used in the linked blog posts. I am no REST expert, but I don't see how REST would apply here.

I would seriously suggest not to try to modify the UI, but to try an Advisor/precondition.

I am also concerned that what the customer wants to do does not increase quality at all, if, for example, it enforces changing planned for after a work item has been closed and completed for like 3 years. So be careful. I still remember times where I came to work only to find out I had to spend three hours of my day to update mandatory attributes on closed work items and invent data, just because some genius came up with these useless required attributes over night and did not consider completed work. It is also not contributing to quality.

Your answer


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