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)
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.