The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

SWAPNIL SRIVASTAV
Contributor
December 2, 2019

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Leonard Chew
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 Champions.
December 2, 2019

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
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 Champions.
December 2, 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>")
SWAPNIL SRIVASTAV
Contributor
December 3, 2019

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

Leonard Chew
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 Champions.
December 3, 2019

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

 

Mary Mark
April 27, 2023

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. 

 

import com.atlassian.jira.component.ComponentAccessor

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
return ComponentAccessor.groupManager.isUserInGroup(currentUser," Managing Team")
Thanks,
Mary