Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Hide custom field when issue in certain status

Hello,

Can somebody help me with this. I need to hide custom filed type (html) when issue arrives in certain status.

I'm trying to do that with Behaviors plugin as following 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.user.ApplicationUser
import com.onresolve.jira.groovy.user.FieldBehaviours


ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();


def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = getFieldById("customfield_12345")

if (Issue.getStatus() == "TOTO"){
cField.setHidden(true)

}

else {

cField.setHidden(false)

}

But in does not work. I have configure the behavior to my project and custom field as in example here https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html?utm_source=product-help 

What I'm doing wrong ?

Thanks in advance !

1 answer

0 votes
Tarun Sapra Community Leader Dec 14, 2018

Hello @oks

When you add a behaviour to a field then the script is triggered when the field is changed. But in your case your hiding the field only when the status changes, thus your script should be triggered on the status change and need not be linked ot the field. 

My suggestion to you is to add the script in the "initializer function" instead of mapping it to a field and for issue object use - 

underlyingIssue

LIke

if (underlyingIssue.getStatus().getName() == "<Your status here>") {
 //hide the field you want
}

Hi, thank you for answer !

I added the script to "initializer function"  instead of field section and changed to 

underlyingIssue

like that 

if (underlyingIssue.getStatusObject().getName() == "MyStatus"){
cField.setHidden(false)
}

But field is still visible when ticket is in "MyStatus" or changed status to "MyStatus"  :(

Tarun Sapra Community Leader Dec 14, 2018

Hello @oks

In order to hide the field you should code

cField.setHidden(true)

But you are writing

cField.setHidden(false)

Oh, sorry . It was (true) indeed in my code, just mistype here ..

@Tarun Sapra Hi!

In this case, the field is hidden on the edit screen, how to hide on the view screen ?

behaviours doesn't work on view screens

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Management

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

299 views 13 14
View question

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you