Custom work item control x ReadOlny rule

Folks,

I'm writing a custom work item control and I can't manage to access the ReadOnly rule value from inside the control. The ReadOnly property (implemented from IWorkItemControl) is called twice when the form is loading, but after that it is never called again. Here follows the work item definition regarding this context:

<FIELD name="the name" refname="MyField" type="String">
<HELPTEXT>something...</HELPTEXT>
<ALLOWEDVALUES>
<LISTITEM value="Passed" />
<LISTITEM value="Failed" />
</ALLOWEDVALUES>
</FIELD>

<STATE value="MyState">
<FIELDS>
<FIELD refname="MyField">
<READONLY />
</FIELD>
</FIELDS>
</STATE>

As you can imagine, I was expecting to receive "ReadOnly = True" when the work item is in the "MyState" state, but for my surprise, the property reports always "False".

Regards,
Max



Answer this question

Custom work item control x ReadOlny rule

  • Skugga

    Hi Max, the ReadOnly property of IWorkItemControl gets set only at the beginning (as you noticed) based on the workitemtype xml settings. If user sets that readonly to true that means that WIT XML admin wants that field to be always readonly, irrespective of what the rules might say. So in InvalidateDatasource event, you need to take both into account and set control's enabled state using below logic (assuming m_readOnly is set in IWorkItemControl.Readonly and m_field is associated Field object):

    control.Enabled = !m_readOnly && m_field.IsEditable



  • Custom work item control x ReadOlny rule