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

1 vote

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

765 views 2 19
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