Can't hide Comment field on Edit screen using methods provided Edited

Discovered the following resources, but had no luck implementing the solutions they provided to achieve the above:

https://community.atlassian.com/t5/Jira-questions/JIRA-Edit-Screen-Remove-quot-Comment-quot-input/qaq-p/21871

https://jira.atlassian.com/browse/JRASERVER-12244

 I tried all scripts provided, and in all cases, the custom "Hidden" field does get hidden on the Edit screen, but doesn't hide the Comment field (on any screen), which is what I'm trying to achieve. I checked to make sure that there's a separate Screen associated with each Issue Operation (Create/Edit/View) in the Screen Scheme, as I thought that that might be the issue. I made sure to place the script in the Description, and I believe that that part was done correctly as, otherwise, the Hidden field wouldn't be hidden (when I remove the script from the Hidden field's Description, it shows up in the Edit screen, and only the Edit screen). Reindexed (as JIRA kept yelling at my to do so), but that didn't change anything (as expected). Currently running 7.3.3.

Someone mentioned that this can be done using Behaviours as well, so if anyone can provide some direction on how, that would be great as well (in case we can't get the script method to work). There was also a mention of using a CSS Banner method (which I successfully used to hide the Assign button on the View screen using info from another thread), but the example given is for a Transition, and I assume that I would need Screen ID instead of a Transition ID to get that to work.

Looking forward to hearing your suggestions :D

2 answers

1 accepted

Daniel,

A behaviour script like this should hide the comment field on the "Edit" screen but not any other screen. 

def commentField = getFieldById(getFieldChanged())
if (getFieldScreen().name == "Default Screen" && !getActionName()) { // check if on edit screen
commentField.setHidden(true)
}

Screen Shot 2017-11-21 at 11.53.10 AM.png

Josh

Thank you so much Josh!! I set things up exactly as you have them in your screenshot, but unfortunately, with that code, it's not being hidden anywhere. I'm wondering if this is the same reason why the java code didn't work either. Any ideas on what I should check on our setup?

Well, I'm using JIRA out of the box with no modifications. If you've changed the Screen Schemes, I think it'd be possible for the code to no longer work.

What if you just do this? getActionName() should always return null for the Edit screen, so it will make the comment field hidden.

def commentField = getFieldById(getFieldChanged())
if (!getActionName()) { // check if on edit screen
commentField.setHidden(true)
}

You, sir, are a genius!! That did the trick!! Thank you so much for all your help!

Anything I need to keep an eye on with this new code (i.e. unforeseen consequences)?

Yes. In addition to hiding the field on the "Edit" screen, this code will hide the comment field on non-workflow screens like "Assign Issue." If you click the "Assign" button, I think you'll see that the screen will no longer have a comment field. 

A better way to do it would be to check for the field screen name. Go to "Screen Schemes" in JIRA and find the one of "Edit." My screen name is "Default Screen", as I have not modified any schemes. Yours is likely to be different from the sound of it. See image below.

Screen Shot 2017-11-21 at 12.42.42 PM.png

Once we know what the field screen name really is, we can edit my original script to make it work in a behaviour.

Awesome, that was definitely it, and sorry I missed the part in your original code for the screen name variable (otherwise that would have worked to begin with)!

Excellent customer service, thank you again Josh!! If I could, I would totally give you 5 stars :D

Glad I could help, Daniel! Thanks for using ScriptRunner!

1 vote
Alexey Matveev Community Champion Nov 21, 2017

Hello,

Can you use Adaptivist Scriptrunner or you need a javascript code? In Scriptrunner you can use behaviours and you do not need to write any code. You just add a behaviour, then add the comment field to the behaviour and mark the comment field as hidden. That would be all you have to do. It would be hidden on all transation screens. If you need a specific transaction, then you can also configure it in behaviours.

Hey Alexey,

Thank you for your speedy reply! As I said above, I don't mind using either method, as long as it works to hide the Comment field JUST on the Edit screen. Is there any chance you can provide some instructions on how to properly do it using Behaviours? Here's what I've done so far:

1) Created Behaviour (named it HideCommentFieldEditScreen)

2) Added mapping for All Projects/All Issue Types

3) Clicked on Fields, added Comment field, clicked Hide

4) Checked a test ticket, and the Comment field is gone from all screens/transitions (except the View screen)

I'm assuming that I would have to add either a serverside script or an initializer to get it to limit the hiding to only the Edit screen, and that's where I'm stuck.

Hope that you or @Joshua Yamdogo [Adaptavist] (who was awesome with my last question) can guide me with the above ;)

Joshua Yamdogo [Adaptavist]Joshua Yamdogo [Adaptavist]

 

I tried to use the above same code to hide a message custom field on edit screen,but its not working

def PRField = getFieldById(getFieldChanged())
if (!getActionName()) { // check if on edit screen
PRField.setHidden(true)
}

 

Any help on this?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

798 views 5 7
Read article

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