HowTo Update Read Only Field in Work Item

19 באוקטובר 2006

תגובה אחת

As you all must know, there are no built-in client events in the IDE for editing work items. Since some time we just cannot do without it, we wrote a small add-in that does the job by listening to the ‘OnUpdate’ and ‘OnSaving’ events.
 
Using the add-in is very straightforward for most scenarios (so we do not bother you with the boring details…), in this post we’d like to tell you about a tricky and interesting scenario we came across.
 
One of our work items includes a field, which is ReadOnly, we display data to the users but do not let them do any editing. Still, we need to update the field while the work item is being saved. And this is exactly the problem, the add-in is running under the exact permissions as our user, so if the user cannot edit the field, so does the add-in.
 
Like all good things, the solution is nice and simple: we defined another field, a hidden field:
 
<FIELD name="ReadOnlyTrigger" refname="SRL.ReadOnlyTrigger" type="String" />   
 
 
Then, we added some logic: the user (and add-in) cannot write to the Log field only when the hidden field is empty:
 
<FIELD name="ReadOnlyTrigger" refname="SRL.ReadOnlyTrigger" type="String" >   
            <COPY from="value" value="" />
</FIELD>
 
Now, we can define our readonly field as follows
 
<FIELD name="ReadOnlyField" refname="SRL.ReadOnlyField" type="String" >   
<WHEN filed="ReadOnlyTrigger" value="">
    <READONLY />
</WHEN>
 
Note that the ‘copy’ instruction makes sure that the filed is empty, and hence ReadOnly, each time the work item is loaded. When saving the work item, the add-in first writes something to the hidden field, which opens the Log file for writing.

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

תגובה אחת

  1. mike12 בינואר 2007 ב 13:30

    Great solution, but theres a little error in the third code snippet. It should be:




    Otherway it doesn´t work in my solution.

    הגב