Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi
I am very new to scripting. I have a requirement to set Issue linking mandatory while creating an issue.
I have to set Linked issues to "is part of" (inward link) and also in issues field, it should only show tickets from that same project only.
However to make it mandatory I used behavior and added below code.
getFieldById("issuelinks-linktype").setFormValue("is part of").setReadOnly(true)
getFieldById('issuelinks-issues').setReadOnly(false)
for some part, it is working fine. It is making issue linking mandatory while creating the issue also link type is set to "Is part of"
But the main problem is whenever I am trying to edit one issue, at that time even if there is already an existing link it is again asking to fill in the linking issue-issue filed.
and is it possible to show issue from the same project only in that issue filed?
any help would be highly appreciable.
Start with this piece of code.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLink
def links = getFieldById('issuelinks')
def linksValue = links.getValue()
def linkType = getFieldById("issuelinks-linktype")
def linkTypeValue = linkType.getValue()
def linkField = getFieldById('issuelinks-issues')
def linkFieldValue = linkField.getValue()
def existingLinks = ComponentAccessor.getIssueLinkManager().getInwardLinks(underlyingIssue?.getId())
if (existingLinks?.size() == 0 && linkTypeValue == "is part of") {
links.setRequired(true)
} else {
links.setRequired(false)
}
It should make the link field required on creation and on edit later when there are no existing links but the code will not work when user clicks on the link option under the more or in the link section, for that you will have to write your own JavaScript.
Ravi
Hi @Ravi Sagar _Sparxsys_
Is there way to restrict which issues from which project/same project can be selected only in the linked issue?
by the way thanks the above solution worked like charm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I added the same beahviour code for workflow condition - ( create action) and mapped the corresponding project. it is not making the field "Issue" as mandatory.
I am able to make the Linked issue required field but the associated field "Issue" (with link types) not working on create transition. We want to force the user to enter value (actually link some issue to the issue being created) for linked issues field upon creation.
Also, Tried the following link . but no Luck - https://community.atlassian.com/t5/Jira-questions/Make-quot-Issue-Link-quot-a-required-field-is-not-being-enforced/qaq-p/310724
Please advise.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the behaviour's Guide Workflow
Add a new condition of workflow action of Create (1) for the field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Amit Girme for the reply. It is also working but the only thing is it is not checking for the links in the edit field. :)
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.