Show custom fields and make them readonly at the same time

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

This widget could not be displayed.

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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

170 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you