Show custom fields and make them readonly at the same time

codecentric AG September 28, 2016

I do have a custom field type (A) which I can't make readonly in a certain workflow step with ScriptRunner (It's probably not supported).
Let's say I do have the workflow steps Status 1, Status 2, Status 3 

My workaround is to create a new JIRA custom field (B).

  1. Copy the value of the  customfield (A) into (B) during transition from Status 2 to Status 3 
  2. Customfield (A) is visible in Status 1 and Status 2 
  3. Custom field (B) is not visible in Status 1 and Status 2 
  4. Custom field (B) should be shown in Status 3 and defined as readonly.

Problem with Behaviours is that I cant differentiate between Hiding and making a field Readonly for different statuses.

Is there a way with a script to solve the problem?

Regards,

Joerg

 


 

1 answer

1 accepted

1 vote
Answer accepted
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2016

In a behaviour you can check what workflow step or action you are currently on if you attach a server side script to the initialiser or one of the fields. Please see example #7 here.

You can modify the example to be something like:

if (getActionName() == "Start Progress" || getDestinationStepName() == "Done") { // <7>
    formField.setHidden(false)
    formField.setReadOnly(true)
} else {
    formField.setHidden(true)
}

This should achieve what you want.

Suggest an answer

Log in or Sign up to answer