I created a custom field type, but I found that it has problem working with ScriptRunner’s behavior.
I added a behavior to set the custom field to read-only during some workflow status.
Clicking inline edit button on the custom field opens the full edit dialog as expected. However, Jira loads the edit Velocity template of the custom field type instead of view Velocity template. I was expecting Jira to use the view template instead.
My custom field type extends GenericTextCFType, but the edit/view templates are a lot more than a simple input box. I have a input box with the custom field id as id and name (hidden from view with display: none), and this input has extra attributes “disabled” and class=“clientreadonly” attached by the behavior.
I also checked Jira’s APIs, a field being read-only seems to be never considered at all, the intended way is to exclude the field in edit mode. There’s no such property stored in any of the custom field related classes.
So the only way left is to:
- On page load, check if the hidden input field has class “clientreadonly”. This class is added by ScriptRunner behavior setting the field to read-only. If so, disable my other input fields.
- Setup a MutationObserver to monitor attribute change on the hidden input field. If class clientreadonly is added, disable my other input fields.
I’m still working out how behavior does required. So far I only see the required class being added to the field label.