Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide a field in the ticket (View) for a specific status

Lakshmi CH
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.
March 28, 2025

Hi Team,

Can we hide the "Reason Not Approved" field under the Details section in the ticket view once the team has approved the transition (or ticket)? After a ticket has been approved or closed, we would like the "Reason Not Approved" field to be hidden. This field should only appear when the team rejects a ticket, at which point the reason for the rejection should be documented and visible in the ticket.

I tried with the following behaviour, but it's not working.


 

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 reasonField = getFieldById("Reason Not Approved")

if (underlyingIssue.Issue.getStatus() == "Approved")
{
reasonField.setHidden(true)

}

else {

reasonField.setHidden(false)

}

2 answers

0 votes
Sayed Bares _ServiceRocket_
Community Champion
March 28, 2025

You don't need to use a behaviour for that, add the "Reason Not Approved" field only in View Screen, in your reject transition add a screen and then add "Reason Not Approved" field and make sure to add a validator to make the field mandatory.

Lakshmi CH
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.
March 28, 2025

Thank you for your quick response @Sayed Bares _ServiceRocket_ .

My request here is, We want to see that field when its rejected with reason, but the ticket is approved in the next level, if we already wrote the reason, and again send for the approval, if its is accepted, then logically the reason shouldn't displayed, in case if the ticket is rejected, it should display the reason.

Sayed Bares _ServiceRocket_
Community Champion
March 28, 2025

@Lakshmi CH then try to add a post-function in the approved transition to clear that field.

0 votes
Florian Bonniec
Community Champion
March 28, 2025

Hi @Lakshmi CH 

 

You cannot use Behaviour on the View screen. You could remote it from the view screen and create a custom script fragment that display the value of this field. Then display or not this fragment based on the issue status.

 

Regards

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events