Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Daniel Sabeti November 21, 2017

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

4 answers

1 accepted

3 votes
Answer accepted
Joshua Yamdogo @ Adaptavist
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.
November 21, 2017

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

Daniel Sabeti November 21, 2017

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?

Joshua Yamdogo @ Adaptavist
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.
November 21, 2017

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)
}
Daniel Sabeti November 21, 2017

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)?

Joshua Yamdogo @ Adaptavist
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.
November 21, 2017

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.

Daniel Sabeti November 21, 2017

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

Joshua Yamdogo @ Adaptavist
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.
November 21, 2017

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

Edward Greathouse August 7, 2018

Thank you for the help!

Bojana Vasic December 24, 2018

Hi Joshua Yamdogo @ Adaptavist,

Thanks for sharing this!

As you mentioned above "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. "

Is there a way to avoid hiding a "Comment" filed on the "Assign" issue system screen? But still have it hidden on "Edit" screen...

Many thanks in advance!

Joshua Yamdogo @ Adaptavist
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.
January 8, 2019

Hi @Bojana Vasic ,

You should be able to simply modify the condition to check the action name to see if the "Assign Issue" action has been pressed

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

Perhaps something like this. I've not tested it, but you could add some log.debug statements to see what getActionName() returns when the "Assign Issue" action happens vs the regular Edit action.

Does that make sense?

Regards,

Josh

Andrew Zimmerman _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 14, 2019

Hey Joshua Yamdogo @ Adaptavist and @Bojana Vasic ,

Sorry to resurrect an old thread, but we're attempting to do this same thing here, and Comment in still hidden from the assign issue screen. 

We have not tried adding a log.debug statement yet, but just wanted to first see if you learned the solution here.

Thanks so much!

Andrew

1 vote
Alexey Matveev
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.
November 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.

Daniel Sabeti November 21, 2017

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 ;)

Vineela Durbha January 18, 2018

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?

0 votes
David Harkins
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.
December 2, 2021

Can we go one step further and hide the 'Customer' comments only?

So that even agents can only submit an internal comment on that one screen?

0 votes
Kumar
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.
January 4, 2019

Hi Joshua Yamdogo @ Adaptavist  

Here is my question 

If i Want to Hide the Comment Field on the WorkFlow Transition Screen how can i do that 

The above script that you have mention its hiding on Edit screen which is good

But If i want to Hide on Particular Transition Screen How can I achive that can you please help me with script 

 

Thanks,

Kumar

Anton Shevtsov April 11, 2019

Hi Kumar,

Map the necessary Workflow and add Condition to hide the field on the particular Actions (for transition). See the attached screenshot - 1 - Select Guide workflow; 2 - Add Condition; 3 - select whether hide field on the transition screen or show only on this transition; 4 - select necessary transition.

hide_comment.PNG

Regards,

Anton 

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events