Work Item Rules Workaround: Only the creator of the bug can close the bug

In our last post in this series, Sunder blogged about saving the resolved reason. (You’ve probably figured out that we have “tag-teamed” this blog series). So anyway, here is the next item in the series.  Customers have asked us:

“I only want the creator of the bug to be able to close the bug … no one else”

“Oh … and by the way, I want to be able to have an administrator override and close a bug for anyone”

Another valid request, again which is not handled well with standard implementations of work item rules. In fact, Sunder and I tried and tried to figure this one out, and simply couldn’t come up with a solution.

Then I offered a $5 reward to a developer who said he could figure it out. Well I’m out $5, but now have something to offer to solve this problem. Worth the $5? You can be the judge…

 

Here are the steps:

1) Create ClosedByValidation field and add the following rules:

<FIELD name="Closed By Validation" refname="Demo.ClosedByValidation" type="String">
<COPY from="currentuser" />
<FROZEN not=“[project]\Project Administrators”/> </FIELD>

 

2) Add the following rules to Closed state

<STATE value="Closed">
<FIELDS>
<FIELD refname="Demo.ClosedByValidation">
<COPY from="currentuser" />
</FIELD>
</FIELDS> </STATE>

3) Add the ClosedByValidation field to the form, so it looks like this. Note how I’ve displayed both the “Created By” field and the “ClosedByValidation” field.

image

 

How it works:

  • The ClosedByValidation field copies the “Created By” value into itself right when the work item is created.
  • It then immediately freezes the field (with the FROZEN) rule, which states that it cannot change.
    • NOTE: The FROZEN rule is conditioned to NOT apply to project administrators, giving them an override capability.
  • When the work item is Closed, then the current user is copied into the ClosedByValidation field.
  • If the ClosedByValidation’s value remains the same (the original Created By) then all is well.
  • If the ClosedByValidation’s value has changed, then the FROZEN rule displays a violation as you see in the screenshot above.

Pretty clever Mr. Developer.

image

Comments

  • Anonymous
    April 09, 2009
    Brian Harry on ALM Catalyst workshops and Second annual Team System Conference in Germany The SRL Team

  • Anonymous
    April 24, 2009
    In the last post in this series , Gregg blogged about restricting a bug such that only the creator can

  • Anonymous
    April 24, 2009
    In the last post in this series , Gregg blogged about restricting a bug such that only the creator can