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

How to disable 'Assign to me' functionality for a few specific issues

Hello,

I need to disable the 'Assign to me' link when a custom field has a particular value. I have tried using the Behaviour Script - Initializer as well as Server Side Script, with no avail. Script works fine on Create,Edit and Assign screens.

Could you please help.

Thanks and Regards,

Swapnil Srivastav.

1 answer

1 vote

Hi @SWAPNIL_SRIVASTAV 

Actually you would do it with a script fragment of type "hide element", but the element 'assign-to-me' is not available to hide.

I have a sort of a hack-solution.

You can use a 'Show a web panel' script fragment and inject javascript code to disable the button.

Unfortunately, the button is loaded after the script fragment, so you need to set a delay in your javascript code.

Here is the code:

writer.write('<script>setTimeout(function(){document.getElementById("assign-to-me").style.display = "none"},1000);</script>')

It basically waits for 1 second (for the button to load) and then hides the button.

It's a bit a hack, but the best I came up with. 

And this snippet only hides the button on the edit screen. You can still assign the issue by typing 'i'.

 

The issue will look like this:

hidden link.png

And here is a screenshot of the configuration:

hide assign-link.png

Leonard Chew Community Leader Dec 02, 2019

And here is a better code snippet without needing the timeout function...

It sets a 'global css rule', which automatically hides the link as soon as that is created.

writer.write("<script>var css = '#assign-to-me { display: none; }', head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style');head.appendChild(style);style.appendChild(document.createTextNode(css));</script>")

Hello @Leonard Chew ,

Thank you very much for your response.

I don't need to hide it globally. I need to hide it only for a particular project, only for a particular issue type and on a condition that a custom field has a particular value.

Can that be done using Script Fragments? If yes, could you kindly help me with the Condition part?

Thanks and Regards,

Swapnil Srivastav

This Condition Script will hide the link, if...

  • Type is Epic
  • and the value of the Customfield "Documentation" is "Doc".

 

Condition Script:

import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObjectsByName("Documentation")[0]
def cFieldValue = issue.getCustomFieldValue(cField)

(issue.issueType.name =='Epic' && cFieldValue=='Doc')

 

Suggest an answer

Log in or Sign up to answer
TAGS

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