Can we hide comment field from a specific tab on a screen

Gaurav Arora August 26, 2020

Hello,

I have added a 2nd tab on the edit screen named "New Tab"(just for example) and wanted to ask if we can hide the comment field from only this tab using groovy. If I click on the default tab, the comment field should be there.

Let me know in either case.

Thanks in advance.

I have used below Jquery/JavaScript approach in initializer. Anything in groovy ?

def comment_field = getFieldById("comment")
def myScript = '''
<script>
AJS.$('[role="tab"]').click(function(){

let tabName = document.querySelector("li.active-tab > a[role='tab']").innerHTML;
if(tabName == "<strong>RCA</strong>"){
AJS.$('.comment-input').hide();
}
else{
AJS.$('.comment-input').show();
}
});
</script>
'''
comment_field.setHelpText (myScript)

 

 

1 answer

0 votes
Mathis Hellensberg
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 2, 2020

I tried building a solution for this using scriptrunner behaviours, but the problem is that I don't think you can get information about the current tab which you are on, except for when you initialise the screen which will always result in the default tab being returned.

def comment = getFieldById("comment")
def editTab = getFieldScreen().tabs.find {
return it
}

if (editTab.name.equals("Second Tab")) {
comment.setHidden(true)
} else {
comment.setHidden(false)
}

I hope someone are able to correct me :) 

Gaurav Arora September 3, 2020

Hi @Mathis Hellensberg ,

Thanks for your reply!!

I hope a community leader can help us here.

:-)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events