It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

3 answers

1 accepted

2 votes
Answer 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)
}
Like Andrew Zimmerman likes this

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!

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!

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

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

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?

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

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 Yuriy likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Desk

Tell us how you've implemented Change Management

Hello Community 👋, I'm a product manager at Atlassian, looking at improving change management capabilities across our products. In particular, we're looking at bridging the gap between Dev & ...

299 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you