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.
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:
And here is a screenshot of the configuration:
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>")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This Condition Script will hide the link, if...
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')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can the assign to me link be hidden for specific groups or roles?
I have this in the condition to restrict to a group but it doesn't seem to restrict to group. The "assign to me" link either shows for everyone or nobody.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.