Greetings community,
Is there a possibility to limit the user on which issue type they can select for linking issues (Linked Issue) in Jira by using ScriptRunner?
For example, if I want to link an Issue of type Story, I want to restrict the users only to be able to link the Story Issue to a Task Issuetype.
I am working on Jira Software for Data Center.
Thank you!
Hi @Marko Dev
Welcome to the Community.
For your requirement, using the Server-Side Behaviour for the Linked Issues field would be best.
Below is a working sample code for your reference:-
import com.adaptavist.hapi.jira.issues.Issues
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def linkedIssues = getFieldById(fieldChanged)
def issueLinksIssue = getFieldById("issuelinks-issues")
linkedIssues.clearError()
if (linkedIssues && issueContext.issueType.name == 'Story' && issueLinksIssue.formValue) {
def issueKey = issueLinksIssue.formValue as String
if (Issues.getByKey(issueKey).issueType.name != 'Task') {
linkedIssues.setError('Only Task Types can be selected')
}
}
Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Also please note that in this code I have used a feature from ScriptRunner's HAPI feature. To be able to use this feature, please ensure that you upgrade your ScriptRunner plugin to the latest release, i.e. 8.4.0.
Below is a screenshot of the Behaviour configuration:-
What this script does is that when the issue is either being created/edited or in a transition, it checks on the linked issue type that is selected.
In this case, if the current issue type created or updated is a Story unless the Linked Issue Type selected is Task, it will return an error message.
I hope this helps to answer your question. :-)
Thank you, and Kind regards,
Ram
Hi @Marko Dev
Has your question been answered?
If yes, please accept the answer provided.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @ram
I note this option does not limit the links available using the link issue option from the ops bar. Your example only limits issues based on the create/update function.
Is there a way to achieve this for the screen shown during issue link from the ops-bar?
Thanks,
Sam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your comment, you asked:-
I note this option does not limit the links available using the link issue option from the ops bar. Your example only limits issues based on the create/update function.
Is there a way to achieve this for the screen shown during issue link from the ops-bar?
Could you please clarify what you mean by this? Are you referring to using an obs-bar link to open a create issue dialog?
If yes then it is possible, i.e. when the dialog opens, you can use the Behaviour to trigger when that dialog opens. Otherwise if you want it to work like a transition, then Behaviour may not be the best approach.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_
Close, I’m referring to the ops-bar drop down specifically More > Link
This option allows me to link the current issue to other issues by providing the link type and the issue I want to link.
I want to limit the list of available linkages. However I can’t seem to find anywhere to do it outside of a Create/Edit screen or as a Validator on a transition.
Hopefully we can solve this! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am also looking for a solution to this problem, in the Server instance we used to have a Link Schemes plugin. But on Cloud there does not seem to be a "simple" solution.
When a user creates a link, I'd like to restrict the choices of available links based on the issue type, so that our object model can be enforced.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Gianni Pucciani @Samuel Stephens
I am also looking for this solution, have you guys found it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.