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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,953
Community Members
 
Community Events
184
Community Groups

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

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 Leaders.
Dec 02, 2019 • edited

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 Leaders.
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

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 Leaders.
Dec 03, 2019 • edited

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

 

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

Suggest an answer

Log in or Sign up to answer